DeviceClass v1beta2
apiVersion: resource.k8s.io/v1beta2
import "k8s.io/api/resource/v1beta2"
DeviceClass
DeviceClass 是一种由供应商或管理员提供的资源,包含设备配置和选择器。可以在 claim 的设备请求中引用它来应用这些预设。集群范围。
这是一个 Alpha 类型,需要启用 DynamicResourceAllocation 特性门控。
apiVersion: resource.k8s.io/v1beta2
kind: DeviceClass
metadata (ObjectMeta)
标准对象元数据
spec (DeviceClassSpec),必需
Spec 定义了可以分配的内容以及如何配置它。
这是可变的。消费者必须为类随时可能发生变化做好准备,无论是更新还是替换。Claim 的分配是在分配时基于类中设置的任何内容一次性完成的。
更改 spec 会自动增加 metadata.generation 数字。
DeviceClassSpec
DeviceClassSpec 用于 [DeviceClass] 中,定义了可以分配的内容以及如何配置它。
config ([]DeviceClassConfiguration)
原子性:将在合并期间被替换
Config 定义了适用于通过此类 claim 的每个设备的配置参数。某些类可能由多个驱动程序满足,因此供应商配置的每个实例仅适用于一个驱动程序。
它们被传递给驱动程序,但在分配 claim 时不予考虑。
DeviceClassConfiguration 在 DeviceClass 中使用。
config.opaque (OpaqueDeviceConfiguration)
Opaque 提供了驱动程序特定的配置参数。
OpaqueDeviceConfiguration 包含驱动程序配置参数,其格式由驱动程序供应商定义。
config.opaque.driver (string),必需
Driver 用于确定需要将这些配置参数传递给哪个 kubelet 插件。
驱动程序开发者提供的准入策略可以使用此参数来决定是否需要验证它们。
必须是 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", }, }
那么发生了什么?解码首先使用 json 或 yaml 将序列化数据解组到你的外部 MyAPIObject 中。这会导致原始 JSON 被存储,但未解包。下一步是(使用 pkg/conversion)复制到内部结构体。runtime 包的 DefaultScheme 安装了转换函数,这些函数将解包存储在 RawExtension 中的 JSON,将其转换为正确的对象类型,并将其存储在 Object 中。(TODO:如果对象类型未知,将创建一个 runtime.Unknown 对象并存储。)*
selectors ([]DeviceSelector)
原子性:将在合并期间被替换
通过此类 claim 的每个设备都必须满足每个选择器。
selectors.cel (CELDeviceSelector)
CEL 包含用于选择设备的 CEL 表达式。
CELDeviceSelector 包含用于选择设备的 CEL 表达式。
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):设备的容量,按前缀分组。
示例:考虑一个 driver="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/v1beta2
kind: DeviceClassList
metadata (ListMeta)
标准列表元数据
items ([]DeviceClass),必需
Items 是资源类的列表。
操作
get
读取指定的 DeviceClass
HTTP 请求
GET /apis/resource.k8s.io/v1beta2/deviceclasses/{name}
参数
name (在路径中):string,必需
DeviceClass 名称
pretty (在查询中):string
响应
200 (DeviceClass):OK
401:未授权
list
列出或监视 DeviceClass 类型的对象
HTTP 请求
GET /apis/resource.k8s.io/v1beta2/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):OK
401:未授权
create
创建一个 DeviceClass
HTTP 请求
POST /apis/resource.k8s.io/v1beta2/deviceclasses
参数
body: DeviceClass,必需
dryRun (在查询中):string
fieldManager (在查询中):string
fieldValidation (在查询中):string
pretty (在查询中):string
响应
200 (DeviceClass):OK
201 (DeviceClass):Created
202 (DeviceClass):Accepted
401:未授权
update
替换指定的 DeviceClass
HTTP 请求
PUT /apis/resource.k8s.io/v1beta2/deviceclasses/{name}
参数
name (在路径中):string,必需
DeviceClass 名称
body: DeviceClass,必需
dryRun (在查询中):string
fieldManager (在查询中):string
fieldValidation (在查询中):string
pretty (在查询中):string
响应
200 (DeviceClass):OK
201 (DeviceClass):Created
401:未授权
patch
部分更新指定的 DeviceClass
HTTP 请求
PATCH /apis/resource.k8s.io/v1beta2/deviceclasses/{name}
参数
name (在路径中):string,必需
DeviceClass 名称
body: Patch,必需
dryRun (在查询中):string
fieldManager (在查询中):string
fieldValidation (在查询中):string
force (在查询中):boolean
pretty (在查询中):string
响应
200 (DeviceClass):OK
201 (DeviceClass):Created
401:未授权
delete
删除一个 DeviceClass
HTTP 请求
DELETE /apis/resource.k8s.io/v1beta2/deviceclasses/{name}
参数
name (在路径中):string,必需
DeviceClass 名称
body: DeleteOptions
dryRun (在查询中):string
gracePeriodSeconds (在查询中):integer
ignoreStoreReadErrorWithClusterBreakingPotential (在查询中):boolean
pretty (在查询中):string
propagationPolicy (在查询中):string
响应
200 (DeviceClass):OK
202 (DeviceClass):Accepted
401:未授权
deletecollection
删除 DeviceClass 集合
HTTP 请求
DELETE /apis/resource.k8s.io/v1beta2/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 项目的其他地方进行。