DeviceClass
apiVersion: resource.k8s.io/v1
import "k8s.io/api/resource/v1"
DeviceClass
DeviceClass 是由供应商或管理员提供的资源,其中包含设备配置和选择器。它可以在声明的设备请求中引用,以应用这些预设。集群范围。
这是一个 Alpha 类型,需要启用 DynamicResourceAllocation 功能门控。
apiVersion: resource.k8s.io/v1
kind: DeviceClass
metadata (ObjectMeta)
标准对象元数据
spec (DeviceClassSpec),必需
Spec 定义了可以分配的内容以及如何配置它。
这是可变的。消费者必须做好类随时可能发生变化(因为它们被更新或替换)的准备。声明分配仅在分配时基于类中设置的内容进行一次。
更改 spec 会自动增加 metadata.generation 的值。
DeviceClassSpec
DeviceClassSpec 用于 [DeviceClass] 中,以定义可分配的内容以及如何配置它。
config ([]DeviceClassConfiguration)
原子性:在合并期间将被替换
Config 定义了适用于通过此类别声明的每个设备的配置参数。某些类别可能由多个驱动程序满足,因此供应商配置的每个实例都适用于一个驱动程序。
它们被传递给驱动程序,但在分配声明时不予考虑。
DeviceClassConfiguration 用于 DeviceClass 中。
config.opaque (OpaqueDeviceConfiguration)
Opaque 提供了特定于驱动程序的配置参数。
OpaqueDeviceConfiguration 以驱动程序供应商定义的格式包含驱动程序的配置参数。
config.opaque.driver (string),必需
Driver 用于确定需要将这些配置参数传递给哪个 Kubelet 插件。
驱动程序开发人员提供的admission policy 可以使用此字段来决定是否需要验证它们。
必须是 DNS 子域,并且应以供应商拥有的 DNS 域结尾。
config.opaque.parameters (RawExtension),必需
Parameters 可以包含任意数据。驱动程序开发人员负责处理验证和版本控制。通常包括自识别和版本(Kubernetes 类型的 "kind" + "apiVersion"),以及不同版本之间的转换。
原始数据的长度必须小于或等于 10 Ki。
要使用它,请在您的外部版本化结构中创建一个类型为 RawExtension 的字段,并在您的内部结构中创建一个 Object 字段。您还需要注册各种插件类型。
// 内部包
type MyAPIObject struct { runtime.TypeMeta
json:",inline"
MyPlugin runtime.Objectjson:"myPlugin"
}type PluginA struct { AOption string
json:"aOption"
}// 外部包
type MyAPIObject struct { runtime.TypeMeta
json:",inline"
MyPlugin runtime.RawExtensionjson:"myPlugin"
}type PluginA struct { AOption string
json:"aOption"
}// 在线上传输时,JSON 看起来像这样
{ "kind":"MyAPIObject", "apiVersion":"v1", "myPlugin": { "kind":"PluginA", "aOption":"foo", }, }
那么会发生什么? Decode 首先使用 json 或 yaml 将序列化数据反 marshal 到您的外部 MyAPIObject 中。这会导致 raw JSON 被存储,但不会被解包。下一步是(使用 pkg/conversion)复制到内部结构中。runtime 包的 DefaultScheme 安装了转换函数,这些函数将解包存储在 RawExtension 中的 JSON,将其转换为正确的对象类型,并将其存储在 Object 中。(TODO:如果对象是未知类型,将创建一个 runtime.Unknown 对象并存储。)*
extendedResourceName (string)
ExtendedResourceName 是此类设备的扩展资源名称。此类设备可用于满足 Pod 的扩展资源请求。其格式与 Pod 的扩展资源名称相同。它在集群中的所有设备类别中应是唯一的。如果两个设备类别具有相同的名称,则选择稍后创建的类别来满足 Pod 的扩展资源请求。如果两个类别同时创建,则选择按字母顺序排序靠前的类别的名称。
这是一个 alpha 字段。
selectors ([]DeviceSelector)
原子性:在合并期间将被替换
通过此类别声明的每个设备都必须满足每个选择器。
selectors.cel (CELDeviceSelector)
CEL 包含用于选择设备的 CEL 表达式。
CELDeviceSelector 包含用于选择设备的 CEL 表达式。
selectors.cel.expression (string),必需
Expression 是一个评估单个设备的 CEL 表达式。当所考虑的设备满足所需条件时,它必须评估为 true,否则评估为 false。任何其他结果都是错误,并导致设备分配中止。
表达式的输入是一个名为 "device" 的对象,它具有以下属性:
- driver (字符串): 定义此设备的驱动程序名称。
- attributes (map[string]object): 设备的属性,按前缀分组(例如 device.attributes["dra.example.com"] 评估为一个包含所有以 "dra.example.com" 为前缀的属性的对象)。
- capacity (map[string]object): 设备的容量,按前缀分组。
- allowMultipleAllocations (bool): 设备(v1.34+,启用了 DRAConsumableCapacity 功能)。
示例:考虑一个驱动程序为 "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 字段可用于检查特定驱动程序,无论是作为高级前置条件(例如,您只想考虑来自此驱动程序的设备),还是作为旨在考虑来自不同驱动程序的设备的复合表达式的一部分。
每个属性的值类型由设备定义确定,编写这些表达式的用户必须查阅其特定驱动程序的文档。每个容量的值类型为 Quantity。
如果在 device.attributes 或 device.capacity 中使用未知前缀进行查找,将返回一个空映射。任何对未知字段的引用都将导致评估错误并中止分配。
健壮的表达式应在引用属性之前检查它们是否存在。
为了便于使用,cel.bind() 函数已启用,可用于简化访问具有相同域的多个属性的表达式。例如:
cel.bind(dra, device.attributes["dra.example.com"], dra.someBool && dra.anotherBool)
表达式的长度必须小于或等于 10 Ki。评估成本也根据估计的逻辑步骤数受到限制。
DeviceClassList
DeviceClassList 是类别的集合。
apiVersion: resource.k8s.io/v1
kind: DeviceClassList
metadata (ListMeta)
标准列表元数据
items ([]DeviceClass),必需
Items 是资源类的列表。
操作
get
读取指定的 DeviceClass
HTTP 请求
GET /apis/resource.k8s.io/v1/deviceclasses/{name}
参数
name (在路径中): string,必填
DeviceClass 的名称
pretty (在查询中): string
响应
200 (DeviceClass): 成功
401: 未授权
list
列出或 watch DeviceClass 类型的对象
HTTP 请求
GET /apis/resource.k8s.io/v1/deviceclasses
参数
allowWatchBookmarks (在查询中): boolean
continue (在查询中): string
fieldSelector (在查询中): string
labelSelector (在查询中): string
limit (在查询中): integer
pretty (在查询中): string
resourceVersion (在查询中): string
resourceVersionMatch (在查询中): string
sendInitialEvents (在查询中): boolean
timeoutSeconds (在查询中): integer
watch (在查询中): boolean
响应
200 (DeviceClassList): 成功
401: 未授权
create
创建一个 DeviceClass
HTTP 请求
POST /apis/resource.k8s.io/v1/deviceclasses
参数
body: DeviceClass,必需
dryRun (在查询中): string
fieldManager (在查询中): string
fieldValidation (在查询中): string
pretty (在查询中): string
响应
200 (DeviceClass): 成功
201 (DeviceClass): 已创建
202 (DeviceClass): 已接受
401: 未授权
update
替换指定的 DeviceClass
HTTP 请求
PUT /apis/resource.k8s.io/v1/deviceclasses/{name}
参数
name (在路径中): string,必填
DeviceClass 的名称
body: DeviceClass,必需
dryRun (在查询中): string
fieldManager (在查询中): string
fieldValidation (在查询中): string
pretty (在查询中): string
响应
200 (DeviceClass): 成功
201 (DeviceClass): 已创建
401: 未授权
patch
部分更新指定的 DeviceClass
HTTP 请求
PATCH /apis/resource.k8s.io/v1/deviceclasses/{name}
参数
name (在路径中): string,必填
DeviceClass 的名称
body: Patch,必需
dryRun (在查询中): string
fieldManager (在查询中): string
fieldValidation (在查询中): string
force (在查询中): boolean
pretty (在查询中): string
响应
200 (DeviceClass): 成功
201 (DeviceClass): 已创建
401: 未授权
delete
删除一个 DeviceClass
HTTP 请求
DELETE /apis/resource.k8s.io/v1/deviceclasses/{name}
参数
name (在路径中): string,必填
DeviceClass 的名称
body: DeleteOptions
dryRun (在查询中): string
gracePeriodSeconds (在查询中): integer
ignoreStoreReadErrorWithClusterBreakingPotential (在查询中): boolean
pretty (在查询中): string
propagationPolicy (在查询中): string
响应
200 (DeviceClass): 成功
202 (DeviceClass): 已接受
401: 未授权
deletecollection
删除 DeviceClass 的集合
HTTP 请求
DELETE /apis/resource.k8s.io/v1/deviceclasses
参数
body: DeleteOptions
continue (在查询中): string
dryRun (在查询中): string
fieldSelector (在查询中): string
gracePeriodSeconds (在查询中): integer
ignoreStoreReadErrorWithClusterBreakingPotential (在查询中): boolean
labelSelector (在查询中): string
limit (在查询中): integer
pretty (在查询中): string
propagationPolicy (在查询中): string
resourceVersion (在查询中): string
resourceVersionMatch (在查询中): string
sendInitialEvents (在查询中): boolean
timeoutSeconds (在查询中): integer
响应
200 (Status): OK
401: 未授权
本页面是自动生成的。
如果你打算报告此页面存在的问题,请在问题描述中提及此页面是自动生成的。修复可能需要在 Kubernetes 项目的其他地方进行。