RuntimeClass

RuntimeClass 定义了集群中支持的容器运行时类别。

apiVersion: node.k8s.io/v1

import "k8s.io/api/node/v1"

RuntimeClass

RuntimeClass 定义了集群中支持的容器运行时类别。RuntimeClass 用于确定使用哪种容器运行时来运行 Pod 中的所有容器。RuntimeClass 由用户或集群供应者手动定义,并在 PodSpec 中引用。Kubelet 负责在运行 Pod 之前解析 RuntimeClassName 引用。更多细节,请参阅 https://kubernetes.ac.cn/docs/concepts/containers/runtime-class/


  • apiVersion: node.k8s.io/v1

  • kind: RuntimeClass

  • metadata (ObjectMeta)

    更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

  • handler (字符串), 必须

    handler 指定了 CRI 实现用于处理此类 Pod 的底层运行时和配置。可能的值取决于节点和 CRI 的配置。假定所有 handler 在每个节点上都可用,且同名 handler 在每个节点上是等效的。例如,一个名为 "runc" 的 handler 可能指定将使用 runc OCI 运行时(使用原生 Linux 容器)来运行 Pod 中的容器。Handler 必须为小写,符合 DNS Label (RFC 1123) 的要求,并且是不可变的。

  • overhead (Overhead)

    overhead 表示运行给定 RuntimeClass 的 Pod 所相关的资源开销。更多细节,请参阅 https://kubernetes.ac.cn/docs/concepts/scheduling-eviction/pod-overhead/

    Overhead 结构表示与运行 Pod 相关的资源开销。

    • overhead.podFixed (map[string]Quantity)

      podFixed 表示与运行 Pod 相关的固定资源开销。

  • scheduling (Scheduling)

    scheduling 包含调度约束,以确保使用此 RuntimeClass 运行的 Pod 被调度到支持它的节点上。如果 scheduling 为 nil,则假定所有节点都支持此 RuntimeClass。

    Scheduling 指定支持 RuntimeClass 的节点的调度约束。

    • scheduling.nodeSelector (map[string]string)

      nodeSelector 列出了支持此 RuntimeClass 的节点上必须存在的标签。使用此 RuntimeClass 的 Pod 只能被调度到与此选择器匹配的节点上。RuntimeClass 的 nodeSelector 会与 Pod 现有的 nodeSelector 合并。任何冲突都将导致 Pod 在准入时被拒绝。

    • scheduling.tolerations ([]Toleration)

      原子性:合并时将被替换

      在准入期间,tolerations(排除重复项)会附加到使用此 RuntimeClass 运行的 Pod 上,从而有效地合并 Pod 和 RuntimeClass 容忍的节点集合。

      附加此 Toleration 的 Pod 可以容忍与三重 <key,value,effect> 使用匹配操作符 <operator> 匹配的任何污点。

      • scheduling.tolerations.key (字符串)

        Key 是 toleration 应用的污点键。空表示匹配所有污点键。如果 key 为空,则 operator 必须为 Exists;这种组合意味着匹配所有值和所有键。

      • scheduling.tolerations.operator (字符串)

        Operator 表示键与值之间的关系。有效的 operator 包括 Exists 和 Equal。默认为 Equal。Exists 等同于值的通配符,因此 Pod 可以容忍特定类别的所有污点。

      • scheduling.tolerations.value (字符串)

        Value 是 toleration 匹配的污点值。如果 operator 是 Exists,则 value 应该为空,否则只是一个普通字符串。

      • scheduling.tolerations.effect (字符串)

        Effect 指示要匹配的污点效果。空表示匹配所有污点效果。指定时,允许的值包括 NoSchedule、PreferNoSchedule 和 NoExecute。

      • scheduling.tolerations.tolerationSeconds (int64)

        TolerationSeconds 表示 toleration(必须是 effect NoExecute,否则此字段将被忽略)容忍污点的时间周期。默认情况下不设置,这意味着永久容忍该污点(不驱逐)。零和负值将被系统视为 0(立即驱逐)。

RuntimeClassList

RuntimeClassList 是 RuntimeClass 对象的列表。


操作


get 读取指定的 RuntimeClass

HTTP 请求

GET /apis/node.k8s.io/v1/runtimeclasses/{name}

参数

  • name (在路径中): 字符串, 必须

    RuntimeClass 的名称

  • pretty (在查询中): 字符串

    pretty

响应

200 (RuntimeClass): OK

401: 未授权

list 列出或监听 RuntimeClass 类型的对象

HTTP 请求

GET /apis/node.k8s.io/v1/runtimeclasses

参数

响应

200 (RuntimeClassList): OK

401: 未授权

create 创建一个 RuntimeClass

HTTP 请求

POST /apis/node.k8s.io/v1/runtimeclasses

参数

响应

200 (RuntimeClass): OK

201 (RuntimeClass): 已创建

202 (RuntimeClass): 已接受

401: 未授权

update 替换指定的 RuntimeClass

HTTP 请求

PUT /apis/node.k8s.io/v1/runtimeclasses/{name}

参数

  • name (在路径中): 字符串, 必须

    RuntimeClass 的名称

  • body: RuntimeClass, 必须

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • pretty (在查询中): 字符串

    pretty

响应

200 (RuntimeClass): OK

201 (RuntimeClass): 已创建

401: 未授权

patch 部分更新指定的 RuntimeClass

HTTP 请求

PATCH /apis/node.k8s.io/v1/runtimeclasses/{name}

参数

  • name (在路径中): 字符串, 必须

    RuntimeClass 的名称

  • body: Patch, 必须

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • force (在查询中): boolean

    force

  • pretty (在查询中): 字符串

    pretty

响应

200 (RuntimeClass): OK

201 (RuntimeClass): 已创建

401: 未授权

delete 删除一个 RuntimeClass

HTTP 请求

DELETE /apis/node.k8s.io/v1/runtimeclasses/{name}

参数

响应

200 (Status): OK

202 (Status): 已接受

401: 未授权

deletecollection 删除 RuntimeClass 集合

HTTP 请求

DELETE /apis/node.k8s.io/v1/runtimeclasses

参数

响应

200 (Status): OK

401: 未授权

本页面是自动生成的。

如果您计划报告本页面的问题,请在问题描述中注明本页面是自动生成的。修复可能需要在 Kubernetes 项目的其他地方进行。

最后修改于 2025 年 4 月 9 日太平洋标准时间下午 6:36:更新 v1.32 的 API 参考文档 (a3b579d035)