大网数据广告活动
Kubernetes 部署与运维

DeviceTaintRule v1alpha3

· 52CE 我爱测

DeviceTaintRule 添加一个污点到与选择算符匹配的所有设备上。 这与通过 DRA 驱动直接在 ResourceSlice 中指定污点具有同样的效果。

apiVersion: resource.k8s.io/v1alpha3

import "k8s.io/api/resource/v1alpha3"

DeviceTaintRule {#DeviceTaintRule}

DeviceTaintRule 添加一个污点到与选择算符匹配的所有设备上。 这与通过 DRA 驱动直接在 ResourceSlice 中指定污点具有同样的效果。

<hr>

  • apiVersion: resource.k8s.io/v1alpha3

  • kind: DeviceTaintRule

  • metadata (<a href="">ObjectMeta</a>)

    标准的对象元数据。

  • spec (<a href="">DeviceTaintRuleSpec</a>),必需

    spec 指定选择算符和一个污点。

    自动更改 spec 会让 metadata.generation 数值加一。

DeviceTaintRuleSpec {#DeviceTaintRuleSpec}

DeviceTaintRuleSpec 指定选择算符和一个污点。

<hr>

  • taint (DeviceTaint),必需

    应用到匹配设备的污点。

    <a name="DeviceTaint"></a> 挂接了此污点的设备会对任何不容忍此污点的申领产生“影响”,并通过此申领影响使用申领的 Pod。

    • taint.effect (string),必需

      对不容忍此污点的申领及使用此申领的 Pod 所产生的影响。 有效值包括 NoSchedule 和 NoExecute。 节点上常用的 PreferNoSchedule 在此无效。

      可能的枚举值:

      • "NoExecute" 驱逐所有已经运行且不容忍设备污点的 Pod。
      • "NoSchedule" 不允许调度新的、使用存在污点设备的 Pod,除非它们能容忍该污点, 但允许所有直接提交给 kubelet 而不通过调度器的 Pod 启动, 并允许所有已经在运行的 Pod 继续运行。
    • taint.key (string),必需

      应用到某设备的污点键。必须是标签名称。

    • taint.timeAdded (Time)

      timeAdded 表示添加污点的时间。如果未设置,意味着在创建或更新期间自动添加。

      <a name="Time"></a> Time 是 time.Time 的包装器,它支持对 YAML 和 JSON 的正确编组。 time 包的许多工厂方法提供了包装器。

    • taint.value (string)

      与污点键对应的污点值。必须是标签值。

  • deviceSelector (DeviceTaintSelector)

    deviceSelector 定义污点应用到哪些设备上。 对于要匹配的设备,必须满足所有选择算符条件。 空选择算符匹配所有设备。如果没有选择算符,则不匹配任何设备。

    <a name="DeviceTaintSelector"></a> DeviceTaintSelector 定义 DeviceTaintRule 应用到哪些设备。 空选择算符匹配所有设备。如果没有选择算符,则不匹配任何设备。

    • deviceSelector.device (string)

      如果设置了 device,则仅选择具有该名称的设备。 此字段对应 slice.spec.devices[].name。

      为避免歧义,也可以设置 driver 和 pool,但不是必需的。

    • deviceSelector.deviceClassName (string)

      如果设置了 deviceClassName,则设备必须满足其中定义的选择算符条件才会被选中。 此字段对应 class.metadata.name。

    • deviceSelector.driver (string)

      如果设置了 driver,则仅选择来自该驱动的设备。此字段对应于 slice.spec.driver。

    • deviceSelector.pool (string)

      如果设置了 pool,则仅选择属于该资源池的设备。

      同时设置 driver 名称可能有助于避免不同驱动使用相同的池名称所带来的歧义,但这不是必需的。 因为从不同驱动中选择池也是有意义的,例如当使用节点本地设备的驱动以节点名称作为 pool 名称时。

    • deviceSelector.selectors ([]DeviceSelector)

      原子性:将在合并期间被替换

      selectors 包含与 ResourceClaim 相同的选择条件。 目前支持 CEL 表达式。必须满足所有这些选择算符。

      <a name="DeviceSelector"></a> DeviceSelector 必须有且仅有一个字段被设置。

      • deviceSelector.selectors.cel (CELDeviceSelector)

        cel 包含一个用于选择设备的 CEL 表达式。

        <a name="CELDeviceSelector"></a> CELDeviceSelector 包含一个用于选择设备的 CEL 表达式。

        • deviceSelector.selectors.cel.expression (string),必需

          expression 是一个 CEL 表达式,用于评估单个设备。 当被考虑的设备满足所需条件时,表达式的求值结果必须为 true;当不满足时, 结果应为 false。任何其他结果都是错误,会导致设备分配中止。

          表达式的输入是一个名为 "device" 的对象,具有以下属性:

          • driver (string):定义此设备的驱动的名称。
          • attributes (map[string]object):设备的属性,按前缀分组 (例如,device.attributes["dra.example.com"] 评估为一个对象,包含所有以 "dra.example.com" 为前缀的属性。)
          • capacity (map[string]object):设备的容量,按前缀分组。

          示例:考虑一个驱动为 "dra.example.com" 的设备,它暴露两个名为 "model" 和 "ext.example.com/family" 的属性,并且暴露一个名为 "modules" 的容量。 此表达式的输入将具有以下字段:

          device.driver
          device.attributes["dra.example.com"].model
          device.attributes["ext.example.com"].family
          device.capacity["dra.example.com"].modules
          

          device.driver 字段可用于检查特定驱动,既可以作为高层次的前提条件(即你只想考虑来自此驱动的设备), 也可以作为考虑来自不同驱动的设备的多子句表达式的一部分。

          attribute 中每个元素的值类型由设备定义,编写这些表达式的用户必须查阅其特定驱动的文档。 capacity 中元素的值类型为 Quantity。

          如果在 device.attributes 或 device.capacity 中使用未知前缀进行查找, 将返回一个空映射。对未知字段的任何引用将导致评估错误和分配中止。

          一个健壮的表达式应在引用属性之前检查其是否存在。

          为了方便使用,cel.bind() 函数被启用,此函数可用于简化访问同一域的多个属性的表达式。 例如:

          cel.bind(dra, device.attributes["dra.example.com"], dra.someBool && dra.anotherBool)
          

          此表达式的长度必须小于或等于 10 Ki。其求值的计算成本也会根据预估的逻辑步骤数进行限制。

DeviceTaintRuleList {#DeviceTaintRuleList}

DeviceTaintRuleList 是 DeviceTaintRules 的集合。

<hr>

  • apiVersion: resource.k8s.io/v1alpha3

  • kind: DeviceTaintRuleList

  • metadata (<a href="">ListMeta</a>)

    标准的列表元数据。

  • items ([]<a href="">DeviceTaintRule</a>),必需

    items 是 DeviceTaintRules 的列表。

操作 {#Operations}

<hr>

get 读取指定的 DeviceTaintRule

HTTP 请求

GET /apis/resource.k8s.io/v1alpha3/devicetaintrules/{name}

参数

  • name (路径参数): string,必需

    DeviceTaintRule 的名称。

  • pretty (查询参数): string

    <a href="">pretty</a>

响应

200 (<a href="">DeviceTaintRule</a>): OK

401: Unauthorized

list 列举或监视类别为 DeviceTaintRule 的对象

HTTP 请求

GET /apis/resource.k8s.io/v1alpha3/devicetaintrules

参数

  • allowWatchBookmarks (查询参数): boolean

    <a href="">allowWatchBookmarks</a>

  • continue (查询参数): string

    <a href="">continue</a>

  • fieldSelector (查询参数): string

    <a href="">fieldSelector</a>

  • labelSelector (查询参数): string

    <a href="">labelSelector</a>

  • limit (查询参数): integer

    <a href="">limit</a>

  • pretty (查询参数): string

    <a href="">pretty</a>

  • resourceVersion (查询参数): string

    <a href="">resourceVersion</a>

  • resourceVersionMatch (查询参数): string

    <a href="">resourceVersionMatch</a>

  • sendInitialEvents (查询参数): boolean

    <a href="">sendInitialEvents</a>

  • timeoutSeconds (查询参数): integer

    <a href="">timeoutSeconds</a>

  • watch (查询参数): boolean

    <a href="">watch</a>

响应

200 (<a href="">DeviceTaintRuleList</a>): OK

401: Unauthorized

create 创建 DeviceTaintRule

HTTP 请求

POST /apis/resource.k8s.io/v1alpha3/devicetaintrules

参数

  • body: <a href="">DeviceTaintRule</a>,必需

  • dryRun (查询参数): string

    <a href="">dryRun</a>

  • fieldManager (查询参数): string

    <a href="">fieldManager</a>

  • fieldValidation (查询参数): string

    <a href="">fieldValidation</a>

  • pretty (查询参数): string

    <a href="">pretty</a>

响应

200 (<a href="">DeviceTaintRule</a>): OK

201 (<a href="">DeviceTaintRule</a>): Created

202 (<a href="">DeviceTaintRule</a>): Accepted

401: Unauthorized

update 替换指定的 DeviceTaintRule

HTTP 请求

PUT /apis/resource.k8s.io/v1alpha3/devicetaintrules/{name}

参数

  • name (路径参数): string,必需

    DeviceTaintRule 的名称。

  • body: <a href="">DeviceTaintRule</a>,必需

  • dryRun (查询参数): string

    <a href="">dryRun</a>

  • fieldManager (查询参数): string

    <a href="">fieldManager</a>

  • fieldValidation (查询参数): string

    <a href="">fieldValidation</a>

  • pretty (查询参数): string

    <a href="">pretty</a>

响应

200 (<a href="">DeviceTaintRule</a>): OK

201 (<a href="">DeviceTaintRule</a>): Created

401: Unauthorized

patch 部分更新指定的 DeviceTaintRule

HTTP 请求

PATCH /apis/resource.k8s.io/v1alpha3/devicetaintrules/{name}

参数

  • name (路径参数): string,必需

    DeviceTaintRule 的名称。

  • body: <a href="">Patch</a>,必需

  • dryRun (查询参数): string

    <a href="">dryRun</a>

  • fieldManager (查询参数): string

    <a href="">fieldManager</a>

  • fieldValidation (查询参数): string

    <a href="">fieldValidation</a>

  • force (查询参数): boolean

    <a href="">force</a>

  • pretty (查询参数): string

    <a href="">pretty</a>

响应

200 (<a href="">DeviceTaintRule</a>): OK

201 (<a href="">DeviceTaintRule</a>): Created

401: Unauthorized

delete 删除 DeviceTaintRule

HTTP 请求

DELETE /apis/resource.k8s.io/v1alpha3/devicetaintrules/{name}

参数

  • name (路径参数): string,必需

    DeviceTaintRule 的名称。

  • body: <a href="">DeleteOptions</a>

  • dryRun (查询参数): string

    <a href="">dryRun</a>

  • gracePeriodSeconds (查询参数): integer

    <a href="">gracePeriodSeconds</a>

  • ignoreStoreReadErrorWithClusterBreakingPotential (查询参数): boolean

    <a href="">ignoreStoreReadErrorWithClusterBreakingPotential</a>

  • pretty (查询参数): string

    <a href="">pretty</a>

  • propagationPolicy (查询参数): string

    <a href="">propagationPolicy</a>

响应

200 (<a href="">DeviceTaintRule</a>): OK

202 (<a href="">DeviceTaintRule</a>): Accepted

401: Unauthorized

deletecollection 删除 DeviceTaintRule 的集合

HTTP 请求

DELETE /apis/resource.k8s.io/v1alpha3/devicetaintrules

参数

  • body: <a href="">DeleteOptions</a>

  • continue (查询参数): string

    <a href="">continue</a>

  • dryRun (查询参数): string

    <a href="">dryRun</a>

  • fieldSelector (查询参数): string

    <a href="">fieldSelector</a>

  • gracePeriodSeconds (查询参数): integer

    <a href="">gracePeriodSeconds</a>

  • ignoreStoreReadErrorWithClusterBreakingPotential (查询参数): boolean

    <a href="">ignoreStoreReadErrorWithClusterBreakingPotential</a>

  • labelSelector (查询参数): string

    <a href="">labelSelector</a>

  • limit (查询参数): integer

    <a href="">limit</a>

  • pretty (查询参数): string

    <a href="">pretty</a>

  • propagationPolicy (查询参数): string

    <a href="">propagationPolicy</a>

  • resourceVersion (查询参数): string

    <a href="">resourceVersion</a>

  • resourceVersionMatch (查询参数): string

    <a href="">resourceVersionMatch</a>

  • sendInitialEvents (查询参数): boolean

    <a href="">sendInitialEvents</a>

  • timeoutSeconds (查询参数): integer

    <a href="">timeoutSeconds</a>

响应

200 (<a href="">Status</a>): OK

401: Unauthorized

来源:Kubernetes 文档贡献者 · 作者与贡献记录 · CC BY 4.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
Kubernetes 文档贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。