# DeviceClass

DeviceClassDeviceClass is a vendor- or admin-provided resource that contains device configuration and selectors.apiVersion: resource.k8s.io/v1import "k8s.io/api/resource/v1"DeviceClassDeviceClass is a vendor- or admin-provided resource that contains device configuration and selectors. It can be referenced in the device requests of a claim to apply these presets. Cluster scoped.This is an alpha type and requires enabling the DynamicResourceAllocation feature gate.apiVersion: resource.k8s.io/v1kind: DeviceClassmetadata (ObjectMeta)Standard object metadataspec (DeviceClassSpec), requiredSpec defines what can be allocated and how to configure it.This is mutable. Consumers have to be prepared for classes changing at any time, either because they get updated or replaced. Claim allocations are done once based on whatever was set in classes at the time of allocation.Changing the spec automatically increments the metadata.generation number.DeviceClassSpecDeviceClassSpec is used in a [DeviceClass] to define what can be allocated and how to configure it.config ([]DeviceClassConfiguration)Atomic: will be replaced during a mergeConfig defines configuration parameters that apply to each device that is claimed via this class. Some classes may potentially be satisfied by multiple drivers, so each instance of a vendor configuration applies to exactly one driver.They are passed to the driver, but are not considered while allocating the claim.DeviceClassConfiguration is used in DeviceClass.config.opaque (OpaqueDeviceConfiguration)Opaque provides driver-specific configuration parameters.OpaqueDeviceConfiguration contains configuration parameters for a driver in a format defined by the driver vendor.config.opaque.driver (string), requiredDriver is used to determine which kubelet plugin needs to be passed these configuration parameters.An admission policy provided by the driver developer could use this to decide whether it needs to validate them.Must be a DNS subdomain and should end with a DNS domain owned by the vendor of the driver.config.opaque.parameters (RawExtension), requiredParameters can contain arbitrary data. It is the responsibility of the driver developer to handle validation and versioning. Typically this includes self-identification and a version ("kind" + "apiVersion" for Kubernetes types), with conversion between different versions.The length of the raw data must be smaller or equal to 10 Ki.*RawExtension is used to hold extensions in external versions.To use this, make a field which has RawExtension as its type in your external, versioned struct, and Object in your internal struct. You also need to register your various plugin types.// Internal package:type MyAPIObject struct { runtime.TypeMeta json:",inline" MyPlugin runtime.Object json:"myPlugin" }type PluginA struct { AOption string json:"aOption" }// External package:type MyAPIObject struct { runtime.TypeMeta json:",inline" MyPlugin runtime.RawExtension json:"myPlugin" }type PluginA struct { AOption string json:"aOption" }// On the wire, the JSON will look something like this:{ "kind":"MyAPIObject", "apiVersion":"v1", "myPlugin": { "kind":"PluginA", "aOption":"foo", }, }So what happens? Decode first uses json or yaml to unmarshal the serialized data into your external MyAPIObject. That causes the raw JSON to be stored, but not unpacked. The next step is to copy (using pkg/conversion) into the internal struct. The runtime package's DefaultScheme has conversion functions installed which will unpack the JSON stored in RawExtension, turning it into the correct object type, and storing it in the Object. (TODO: In the case where the object is of an unknown type, a runtime.Unknown object will be created and stored.)*extendedResourceName (string)ExtendedResourceName is the extended resource name for the devices of this class. The devices of this class can be used to satisfy a pod's extended resource requests. It has the same format as the name of a pod's extended resource. It should be unique among all the device classes in a cluster. If two device classes have the same name, then the class created later is picked to satisfy a pod's extended resource requests. If two classes are created at the same time, then the name of the class lexicographically sorted first is picked.This is an alpha field.selectors ([]DeviceSelector)Atomic: will be replaced during a mergeEach selector must be satisfied by a device which is claimed via this class.DeviceSelector must have exactly one field set.selectors.cel (CELDeviceSelector)CEL contains a CEL expression for selecting a device.CELDeviceSelector contains a CEL expression for selecting a device.selectors.cel.expression (string), requiredExpression is a CEL expression which evaluates a single device. It must evaluate to true when the device under consideration satisfies the desired criteria, and false when it does not. Any other result is an error and causes allocation of devices to abort.The expression's input is an object named "device", which carries the following properties:driver (string): the name of the driver which defines this device.attributes (map[string]object): the device's attributes, grouped by prefix (e.g. device.attributes["dra.example.com"] evaluates to an object with all of the attributes which were prefixed by "dra.example.com".capacity (map[string]object): the device's capacities, grouped by prefix.allowMultipleAllocations (bool): the allowMultipleAllocations property of the device (v1.34+ with the DRAConsumableCapacity feature enabled).Example: Consider a device with driver="dra.example.com", which exposes two attributes named "model" and "ext.example.com/family" and which exposes one capacity named "modules". This input to this expression would have the following fields:device.driver device.attributes["dra.example.com"].model device.attributes["ext.example.com"].family device.capacity["dra.example.com"].modules The device.driver field can be used to check for a specific driver, either as a high-level precondition (i.e. you only want to consider devices from this driver) or as part of a multi-clause expression that is meant to consider devices from different drivers.The value type of each attribute is defined by the device definition, and users who write these expressions must consult the documentation for their specific drivers. The value type of each capacity is Quantity.If an unknown prefix is used as a lookup in either device.attributes or device.capacity, an empty map will be returned. Any reference to an unknown field will cause an evaluation error and allocation to abort.A robust expression should check for the existence of attributes before referencing them.For ease of use, the cel.bind() function is enabled, and can be used to simplify expressions that access multiple attributes with the same domain. For example:cel.bind(dra, device.attributes["dra.example.com"], dra.someBool && dra.anotherBool) The length of the expression must be smaller or equal to 10 Ki. The cost of evaluating it is also limited based on the estimated number of logical steps.DeviceClassListDeviceClassList is a collection of classes.apiVersion: resource.k8s.io/v1kind: DeviceClassListmetadata (ListMeta)Standard list metadataitems ([]DeviceClass), requiredItems is the list of resource classes.Operationsget read the specified DeviceClassHTTP RequestGET /apis/resource.k8s.io/v1/deviceclasses/{name}Parametersname (in path): string, requiredname of the DeviceClasspretty (in query): stringprettyResponse200 (DeviceClass): OK401: Unauthorizedlist list or watch objects of kind DeviceClassHTTP RequestGET /apis/resource.k8s.io/v1/deviceclassesParametersallowWatchBookmarks (in query): booleanallowWatchBookmarkscontinue (in query): stringcontinuefieldSelector (in query): stringfieldSelectorlabelSelector (in query): stringlabelSelectorlimit (in query): integerlimitpretty (in query): stringprettyresourceVersion (in query): stringresourceVersionresourceVersionMatch (in query): stringresourceVersionMatchsendInitialEvents (in query): booleansendInitialEventstimeoutSeconds (in query): integertimeoutSecondswatch (in query): booleanwatchResponse200 (DeviceClassList): OK401: Unauthorizedcreate create a DeviceClassHTTP RequestPOST /apis/resource.k8s.io/v1/deviceclassesParametersbody: DeviceClass, requireddryRun (in query): stringdryRunfieldManager (in query): stringfieldManagerfieldValidation (in query): stringfieldValidationpretty (in query): stringprettyResponse200 (DeviceClass): OK201 (DeviceClass): Created202 (DeviceClass): Accepted401: Unauthorizedupdate replace the specified DeviceClassHTTP RequestPUT /apis/resource.k8s.io/v1/deviceclasses/{name}Parametersname (in path): string, requiredname of the DeviceClassbody: DeviceClass, requireddryRun (in query): stringdryRunfieldManager (in query): stringfieldManagerfieldValidation (in query): stringfieldValidationpretty (in query): stringprettyResponse200 (DeviceClass): OK201 (DeviceClass): Created401: Unauthorizedpatch partially update the specified DeviceClassHTTP RequestPATCH /apis/resource.k8s.io/v1/deviceclasses/{name}Parametersname (in path): string, requiredname of the DeviceClassbody: Patch, requireddryRun (in query): stringdryRunfieldManager (in query): stringfieldManagerfieldValidation (in query): stringfieldValidationforce (in query): booleanforcepretty (in query): stringprettyResponse200 (DeviceClass): OK201 (DeviceClass): Created401: Unauthorizeddelete delete a DeviceClassHTTP RequestDELETE /apis/resource.k8s.io/v1/deviceclasses/{name}Parametersname (in path): string, requiredname of the DeviceClassbody: DeleteOptionsdryRun (in query): stringdryRungracePeriodSeconds (in query): integergracePeriodSecondsignoreStoreReadErrorWithClusterBreakingPotential (in query): booleanignoreStoreReadErrorWithClusterBreakingPotentialpretty (in query): stringprettypropagationPolicy (in query): stringpropagationPolicyResponse200 (DeviceClass): OK202 (DeviceClass): Accepted401: Unauthorizeddeletecollection delete collection of DeviceClassHTTP RequestDELETE /apis/resource.k8s.io/v1/deviceclassesParametersbody: DeleteOptionscontinue (in query): stringcontinuedryRun (in query): stringdryRunfieldSelector (in query): stringfieldSelectorgracePeriodSeconds (in query): integergracePeriodSecondsignoreStoreReadErrorWithClusterBreakingPotential (in query): booleanignoreStoreReadErrorWithClusterBreakingPotentiallabelSelector (in query): stringlabelSelectorlimit (in query): integerlimitpretty (in query): stringprettypropagationPolicy (in query): stringpropagationPolicyresourceVersion (in query): stringresourceVersionresourceVersionMatch (in query): stringresourceVersionMatchsendInitialEvents (in query): booleansendInitialEventstimeoutSeconds (in query): integertimeoutSecondsResponse200 (Status): OK401: UnauthorizedThis page is automatically generated.If you plan to report an issue with this page, mention that the page is auto-generated in your issue description. The fix may need to happen elsewhere in the Kubernetes project.