|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * nodes/nodes-pods-allocate-dra.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: REFERENCE |
| 6 | +[id="nodes-pods-allocate-dra-configure-about_{context}"] |
| 7 | += About GPU allocation objects |
| 8 | + |
| 9 | +// Taken from https://kubernetes.io/docs/concepts/scheduling-eviction/dynamic-resource-allocation/#terminology |
| 10 | +{attribute-based-full} uses the following objects to provide the core graphics processing unit (GPU) allocation functionality. All of these API kinds are included in the `resource.k8s.io/v1beta2` API group. |
| 11 | + |
| 12 | +Device class:: |
| 13 | +A device class is a category of devices that pods can claim and how to select specific device attributes in claims. Some device drivers contain their own device class. Alternatively, an administrator can create device classes. A device class contains a device selector, which is a link:https://cel.dev/[common expression language (CEL)] expression that must evaluate to true if a device satisfies the request. |
| 14 | ++ |
| 15 | +The following example `DeviceClass` object selects any device that is managed by the `driver.example.com` device driver: |
| 16 | ++ |
| 17 | +.Example device class object |
| 18 | +[source,yaml] |
| 19 | +---- |
| 20 | +apiVersion: resource.k8s.io/v1beta1 |
| 21 | +kind: DeviceClass |
| 22 | +metadata: |
| 23 | + name: example-device-class |
| 24 | +spec: |
| 25 | + selectors: |
| 26 | + - cel: |
| 27 | + expression: |- |
| 28 | + device.driver == "driver.example.com" |
| 29 | +---- |
| 30 | + |
| 31 | +Resource slice:: |
| 32 | +The Dynamic Resource Allocation (DRA) driver on each node creates and manages _resource slices_ in the cluster. A resource slice represents one or more GPU resources that are attached to nodes. When a resource claim is created and used in a pod, {product-title} uses the resource slices to find nodes that have access to the requested resources. After finding an eligible resource slice for the resource claim, the {product-title} scheduler updates the resource claim with the allocation details, allocates resources to the resource claim, and schedules the pod onto a node that can access the resources. |
| 33 | + |
| 34 | +Resource claim template:: |
| 35 | +Cluster administrators and operators can create a _resource claim template_ to request a GPU from a specific device class. Resource claim templates provide pods with access to separate, similar resources. {product-title} uses a resource claim template to generate a resource claim for the pod. Each resource claim that {product-title} generates from the template is bound to a specific pod. When the pod terminates, {product-title} deletes the corresponding resource claim. |
| 36 | ++ |
| 37 | +The following example resource claim template requests devices in the `example-device-class` device class. |
| 38 | ++ |
| 39 | +.Example resource claim template object |
| 40 | +[source,yaml] |
| 41 | +---- |
| 42 | +apiVersion: resource.k8s.io/v1beta1 |
| 43 | +kind: ResourceClaimTemplate |
| 44 | +metadata: |
| 45 | + namespace: gpu-test1 |
| 46 | + name: gpu-claim-template |
| 47 | +spec: |
| 48 | +# ... |
| 49 | + spec: |
| 50 | + devices: |
| 51 | + requests: |
| 52 | + - name: gpu |
| 53 | + deviceClassName: example-device-class |
| 54 | +---- |
| 55 | + |
| 56 | +Resource claim:: |
| 57 | +Admins and operators can create a _resource claim_ to request a GPU from a specific device class. A resource claim differs from a resource claim template by allowing you to share GPUs with multiple pods. Also, resource claims are not deleted when a requesting pod is terminated. |
| 58 | ++ |
| 59 | +The following example resource claim template uses CEL expressions to request specific devices in the `example-device-class` device class that are of a specific size. |
| 60 | ++ |
| 61 | +.Example resource claim object |
| 62 | +[source,yaml] |
| 63 | +---- |
| 64 | +apiVersion: resource.k8s.io/v1beta1 |
| 65 | +kind: ResourceClaimTemplate |
| 66 | +metadata: |
| 67 | + namespace: gpu-claim |
| 68 | + name: gpu-devices |
| 69 | +spec: |
| 70 | + spec: |
| 71 | + devices: |
| 72 | + requests: |
| 73 | + - name: 1g-5gb |
| 74 | + deviceClassName: example-device-class |
| 75 | + selectors: |
| 76 | + - cel: |
| 77 | + expression: "device.attributes['driver.example.com'].profile == '1g.5gb'" |
| 78 | + - name: 1g-5gb-2 |
| 79 | + deviceClassName: example-device-class |
| 80 | + selectors: |
| 81 | + - cel: |
| 82 | + expression: "device.attributes['driver.example.com'].profile == '1g.5gb'" |
| 83 | + - name: 2g-10gb |
| 84 | + deviceClassName: example-device-class |
| 85 | + selectors: |
| 86 | + - cel: |
| 87 | + expression: "device.attributes['driver.example.com'].profile == '2g.10gb'" |
| 88 | + - name: 3g-20gb |
| 89 | + deviceClassName: example-device-class |
| 90 | + selectors: |
| 91 | + - cel: |
| 92 | + expression: "device.attributes['driver.example.com'].profile == '3g.20gb'" |
| 93 | +---- |
| 94 | + |
| 95 | +For more information on configuring resource claims, resource claim templates, see link:https://kubernetes.io/docs/concepts/scheduling-eviction/dynamic-resource-allocation/["Dynamic Resource Allocation"] (Kubernetes documentation). |
| 96 | + |
| 97 | +For information on adding resource claims to pods, see "Adding resource claims to pods". |
0 commit comments