# Deploy Workload using DRA ResourceClaim in Kubernetes

September 16, 2025

## Introduction
In the [**first blog**](https://docs.rafay.co/blog/2025/08/23/introduction-to-dynamic-resource-allocation-dra-in-kubernetes/) in the DRA series, we introduced the concept of Dynamic Resource Allocation (DRA) that recently went GA in [Kubernetes v1.34](https://kubernetes.io/blog/2025/08/27/kubernetes-v1-34-release/) which was released end of August 2025.

In the [**second blog**](https://docs.rafay.co/blog/2025/08/28/enable-dynamic-resource-allocation-dra-in-kubernetes/), we installed a Kubernetes v1.34 cluster and deployed an example DRA driver on it with "simulated GPUs". In **this blog**, we’ll deploy a few workloads on the DRA-enabled Kubernetes cluster to understand how "Resource Claim" and "ResourceClaimTemplates" work.

## Deploy Test Workload with ResourceClaim
This section assumes that you have completed the steps in the second blog and have access to a functional Kubernetes cluster with DRA configured and enabled. We will deploy **example workloads** that demonstrate how ResourceClaims can be used to select and configure resources in various ways.

Let's create a **ResourceClaim** which we will reference in a Pod. Note that the deviceClassName is a required field because it helps narrow down the scope of the request to a specific device class. In the example below, the ResourceClaim called "some-gpu" will be created in the same namespace (dra-tutorial) we created in the previous blog.

### ResourceClaim YAML
Copy the YAML below and save it to a file called "resourceclaim.yaml". This will allow us to create a request for any GPU advertising over 10Gi memory capacity.

```yaml
apiVersion: resource.k8s.io/v1
kind: ResourceClaim
metadata:
 name: some-gpu
 namespace: dra-tutorial
spec:
   devices:
     requests:
     - name: some-gpu
       exactly:
         deviceClassName: gpu.example.com
         selectors:
         - cel:
             expression: "device.capacity['gpu.example.com'].memory.compareTo(quantity('10Gi')) >= 0"
```

### Create ResourceClaim
Let's create this ResourceClaim using kubectl.

```bash
kubectl apply -f resourceclaim.yaml --server-side
```

### Check ResourceClaim
Now, check if it was created successfully by typing the following command:

```bash
kubectl get resourceclaim -n dra-tutorial
NAME       STATE     AGE
some-gpu   pending   23s
```

## Deploy Workload
Now, let us create a pod that references the ResourceClaim called "some-gpu" we created in the previous step.

```yaml
apiVersion: v1
kind: Pod
metadata:
  name: pod0
  namespace: dra-tutorial
  labels:
    app: pod
spec:
  containers:
  - name: ctr0
    image: ubuntu:24.04
    command: ["bash", "-c"]
    args: ["export; trap 'exit 0' TERM; sleep 9999 & wait"]
    resources:
      claims:
      - name: gpu
  resourceClaims:
  - name: gpu
    resourceClaimName: some-gpu
```

### Create Pod
Copy the YAML above and save it to a file called "pod0.yaml". Now, deploy to the Kubernetes cluster.

```bash
kubectl apply -f pod0.yaml -n dra-tutorial --server-side
```

## Validate DRA Usage
Let's check the status of the pod by issuing the following command:

```bash
kubectl get pod pod0 -n dra-tutorial
```

You should see something like the following:

```bash
NAME   READY   STATUS    RESTARTS   AGE
pod0   1/1     Running   0          61s
```

### Check Resource Claim
Now, let's check the status of our ResourceClaim:

```bash
kubectl get resourceclaims -n dra-tutorial
```

### Detailed ResourceClaim Information
As you can see from the output below:

```bash
kubectl get resourceclaim some-gpu -n dra-tutorial -o yaml
```

### ResourceClaim Example Output
```yaml
apiVersion: resource.k8s.io/v1
kind: ResourceClaim
metadata:
  creationTimestamp: "2025-09-16T21:25:15Z"
  finalizers:
  - resource.kubernetes.io/delete-protection
  name: some-gpu
  namespace: dra-tutorial
  resourceVersion: "780"
  uid: 0902160b-2b3f-4350-86e6-6d47f09958bd
spec:
  devices:
    requests:
    - exactly:
        allocationMode: ExactCount
        count: 1
        deviceClassName: gpu.example.com
        selectors:
        - cel:
            expression: device.capacity['gpu.example.com'].memory.compareTo(quantity('10Gi'))
              >= 0
      name: some-gpu
status:
  allocation:
    devices:
      results:
      - device: gpu-4
        driver: gpu.example.com
        pool: dra-test-control-plane
        request: some-gpu
    nodeSelector:
      nodeSelectorTerms:
      - matchFields:
        - key: metadata.name
          operator: In
          values:
          - dra-test-control-plane
  reservedFor:
  - name: pod0
    resource: pods
    uid: a3e18c4a-7cb7-409e-9d64-9c3e79819b76
```

## Delete Pod
When our pod with the resource claim is deleted, the DRA driver will deallocate the GPU so it can be available for scheduling again. In this step, we will delete the pod that we created in the previous step.

```bash
kubectl delete pod pod0 -n dra-tutorial
```

## Clean Up
If you wish to clean up everything, you can delete the Kind cluster we provisioned earlier by issuing the following command.

```bash
kind delete cluster --name dra-test
```

## Conclusion
In this blog, we deployed a test workload that was using a ResourceClaim to select and configure GPU resources using DRA. In the next blog, we will deploy a test workload that will use ResourceClaimTemplates.
