Allocate Devices to Workloads with DRA [page]deterministic
This page shows you how to allocate devices to your Pods by using _dynamic resource allocation (DRA)_. These instructions are for workload operators. Before reading this page, familiarize yourself with how DRA works and with DRA terminology like [ResourceClaims](#gloss:resourceclaim) and [ResourceClaimTemplates](#gloss:resourceclaimtemplate). For more information, see [Dynamic Resource Allocation (DRA)](/docs/concepts/scheduling-eviction/dynamic-resource-allocation/).
## About device allocation with DRA {#about-device-allocation-dra}
As a workload operator, you can _claim_ devices for your workloads by creating ResourceClaims or ResourceClaimTemplates. When you deploy your workload, Kubernetes and the device drivers find available devices, allocate them to your Pods, and place the Pods on nodes that can access those devices.
##
* Ensure that your cluster admin has set up DRA, attached devices, and installed drivers. For more information, see [Set Up DRA in a Cluster](/docs/tasks/configure-pod-container/assign-resources/set-up-dra-cluster).
## Identify devices to claim {#identify-devices}
Your cluster administrator or the device drivers create _[DeviceClasses](#gloss:deviceclass)_ that define categories of devices. You can claim devices by using [cel](#gloss:cel) to filter for specific device properties.
Get a list of DeviceClasses in the cluster:
```shell kubectl get deviceclasses ``` The output is similar to the following:
``` NAME AGE driver.example.com 16m ``` If you get a permission error, you might not have access to get DeviceClasses. Check with your cluster administrator or with the driver provider for available device properties.
## Claim resources {#claim-resources}
You can request resources from a DeviceClass by using [ResourceClaims](#gloss:resourceclaim). To create a ResourceClaim, do one of the following:
* Manually create a ResourceClaim if you want multiple Pods to share access to the same devices, or if you want a claim to exist beyond the lifetime of a Pod. * Use a [ResourceClaimTemplate](#gloss:resourceclaimtemplate) to let Kubernetes generate and manage per-Pod ResourceClaims. Create a ResourceClaimTemplate if you want every Pod to have access to separate devices that have similar configurations. For example, you might want simultaneous access to devices for Pods in a Job that uses [parallel execution](/docs/concepts/workloads/controllers/job/#parallel-jobs).
If you directly reference a specific ResourceClaim in a Pod, that ResourceClaim must already exist in the cluster. If a referenced ResourceClaim doesn't exist, the Pod remains in a pending state until the ResourceClaim is created. You can reference an auto-generated ResourceClaim in a Pod, but this isn't recommended because auto-generated ResourceClaims are bound to the lifetime of the Pod that triggered the generation.
To create a workload that claims resources, select one of the following options:
Review the following example manifest:
This manifest creates a ResourceClaimTemplate that requests devices in the `example-device-class` DeviceClass that match both of the following parameters:
* Devices that have a `driver.example.com/type` attribute with a value of `gpu`. * Devices that have `64Gi` of capacity.
To create the ResourceClaimTemplate, run the following command:
```shell kubectl apply -f https://k8s.io/examples/dra/resourceclaimtemplate.yaml ```
Review the following example manifest:
This manifest creates ResourceClaim that requests devices in the `example-device-class` DeviceClass that match both of the following parameters:
* Devices that have a `driver.example.com/type` attribute with a value of `gpu`. * Devices that have `64Gi` of capacity.
To create the ResourceClaim, run the following command:
```shell kubectl apply -f https://k8s.io/examples/dra/resourceclaim.yaml ```
## Request devices in workloads using DRA {#request-devices-work …(trimmed)