# Set Up DRA in a Cluster

Set Up DRA in a ClusterFEATURE STATE: Kubernetes v1.34 [stable] (enabled by default: true)This page shows you how to configure dynamic resource allocation (DRA) in a Kubernetes cluster by enabling API groups and configuring classes of devices. These instructions are for cluster administrators.About DRAA Kubernetes feature that lets you request and share resources among Pods. These resources are often attached devices like hardware accelerators.With DRA, device drivers and cluster admins define device classes that are available to claim in workloads. Kubernetes allocates matching devices to specific claims and places the corresponding Pods on nodes that can access the allocated devices.Ensure that you're familiar with how DRA works and with DRA terminology like DeviceClasses, ResourceClaims, and ResourceClaimTemplates. For details, see Dynamic Resource Allocation (DRA).Before you beginYou need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to run this tutorial on a cluster with at least two nodes that are not acting as control plane hosts. If you do not already have a cluster, you can create one by using minikube or you can use one of these Kubernetes playgrounds:iximiuz LabsKillercodaKodeKloudPlay with KubernetesYour Kubernetes server must be version v1.34.To check the version, enter kubectl version.Directly or indirectly attach devices to your cluster. To avoid potential issues with drivers, wait until you set up the DRA feature for your cluster before you install drivers.Optional: enable legacy DRA API groupsDRA graduated to stable in Kubernetes 1.34 and is enabled by default. Some older DRA drivers or workloads might still need the v1beta1 API from Kubernetes 1.30 or v1beta2 from Kubernetes 1.32. If and only if support for those is desired, then enable the following API groups:* `resource.k8s.io/v1beta1` * `resource.k8s.io/v1beta2` For more information, see Enabling or disabling API groups.Verify that DRA is enabledTo verify that the cluster is configured correctly, try to list DeviceClasses:kubectl get deviceclasses If the component configuration was correct, the output is similar to the following:No resources found If DRA isn't correctly configured, the output of the preceding command is similar to the following:error: the server doesn't have a resource type "deviceclasses" Try the following troubleshooting steps:Reconfigure and restart the kube-apiserver component.If the complete .spec.resourceClaims field gets removed from Pods, or if Pods get scheduled without considering the ResourceClaims, then verify that the DynamicResourceAllocation feature gate is not turned off for kube-apiserver, kube-controller-manager, kube-scheduler or the kubelet.Install device driversAfter you enable DRA for your cluster, you can install the drivers for your attached devices. For instructions, check the documentation of your device owner or the project that maintains the device drivers. The drivers that you install must be compatible with DRA.To verify that your installed drivers are working as expected, list ResourceSlices in your cluster:kubectl get resourceslices The output is similar to the following:NAME NODE DRIVER POOL AGE cluster-1-device-pool-1-driver.example.com-lqx8x cluster-1-node-1 driver.example.com cluster-1-device-pool-1-r1gc 7s cluster-1-device-pool-2-driver.example.com-29t7b cluster-1-node-2 driver.example.com cluster-1-device-pool-2-446z 8s Try the following troubleshooting steps:Check the health of the DRA driver and look for error messages about publishing ResourceSlices in its log output. The vendor of the driver may have further instructions about installation and troubleshooting.Create DeviceClassesYou can define categories of devices that your application operators can claim in workloads by creating DeviceClasses. Some device driver providers might also instruct you to create DeviceClasses during driver installation.The ResourceSlices that your driver publishes contain information about the devices that the driver manages, such as capacity, metadata, and attributes. You can use Common Expression Language to filter for properties in your DeviceClasses, which can make finding devices easier for your workload operators.To find the device properties that you can select in DeviceClasses by using CEL expressions, get the specification of a ResourceSlice:kubectl get resourceslice <resourceslice-name> -o yaml The output is similar to the following:apiVersion: resource.k8s.io/v1 kind: ResourceSlice # lines omitted for clarity spec: devices: - attributes: type: string: gpu capacity: memory: value: 64Gi name: gpu-0 - attributes: type: string: gpu capacity: memory: value: 64Gi name: gpu-1 driver: driver.example.com nodeName: cluster-1-node-1 # lines omitted for clarity You can also check the driver provider's documentation for available properties and values.Review the following example DeviceClass manifest, which selects any device that's managed by the driver.example.com device driver:dra/deviceclass.yaml apiVersion: resource.k8s.io/v1 kind: DeviceClass metadata: name: example-device-class spec: selectors: - cel: expression: |- device.driver == "driver.example.com" Create the DeviceClass in your cluster:kubectl apply -f https://k8s.io/examples/dra/deviceclass.yaml Clean upTo delete the DeviceClass that you created in this task, run the following command:kubectl delete -f https://k8s.io/examples/dra/deviceclass.yaml What's nextLearn more about DRAAllocate Devices to Workloads with DRA