2
2
title : Install Drivers and Allocate Devices with DRA
3
3
content_type : tutorial
4
4
weight : 60
5
- min-kubernetes-server-version : v1.32
5
+ min-kubernetes-server-version : v1.34
6
6
---
7
7
<!-- FUTURE MAINTAINERS:
8
8
The original point of this doc was for people (mainly cluster administrators) to
@@ -55,9 +55,9 @@ new fields in the Pod spec itself.
55
55
## {{% heading "prerequisites" %}}
56
56
57
57
Your cluster should support [ RBAC] ( /docs/reference/access-authn-authz/rbac/ ) .
58
- You can try this tutorial with a cluster using
59
- a different authorization mechanism, but in that case you will have to adapt the
60
- steps around defining roles and permissions.
58
+ You can try this tutorial with a cluster using a different authorization
59
+ mechanism, but in that case you will have to adapt the steps around defining
60
+ roles and permissions.
61
61
62
62
{{< include "task-tutorial-prereqs.md" >}}
63
63
@@ -66,27 +66,9 @@ other types of nodes.
66
66
67
67
{{< version-check >}}
68
68
69
- Your cluster also must be configured to use the Dynamic Resource Allocation
70
- feature.
71
- To enable the DRA feature, you must enable the following feature gates and API groups:
72
-
73
- 1 . Enable the ` DynamicResourceAllocation `
74
- [ feature gate] ( /docs/reference/command-line-tools-reference/feature-gates/ )
75
- on all of the following components:
76
-
77
- * ` kube-apiserver `
78
- * ` kube-controller-manager `
79
- * ` kube-scheduler `
80
- * ` kubelet `
81
-
82
- 1 . Enable the following
83
- {{< glossary_tooltip text="API groups" term_id="api-group" >}}:
84
-
85
- * ` resource.k8s.io/v1beta1 `
86
- * ` resource.k8s.io/v1beta2 `
87
-
88
- For more information, see
89
- [ Enabling or disabling API groups] ( /docs/reference/using-api/#enabling-or-disabling ) .
69
+ If your cluster is not currently running Kubernetes {{< skew currentVersion
70
+ > }} then please check the documentation for the version of Kubernetes that you
71
+ plan to use.
90
72
91
73
92
74
<!-- lessoncontent -->
@@ -174,7 +156,7 @@ dra-example-driver to simulate access to a DRA driver image.
174
156
from within one of your cluster' s nodes:
175
157
176
158
```shell
177
- docker pull registry.k8s.io/dra-example-driver/dra-example-driver:v0.1 .0
159
+ docker pull registry.k8s.io/dra-example-driver/dra-example-driver:v0.2 .0
178
160
```
179
161
180
162
### Deploy the DRA driver components
@@ -363,7 +345,7 @@ variables to see how the Pods have been handled by the system.
363
345
364
346
The output is similar to this:
365
347
```
366
- declare -x GPU_DEVICE_4 ="gpu-4 "
348
+ declare -x GPU_DEVICE_0 ="gpu-0 "
367
349
```
368
350
369
351
1. Check the state of the ResourceClaim object:
@@ -391,54 +373,48 @@ variables to see how the Pods have been handled by the system.
391
373
```
392
374
393
375
The output is similar to this:
394
- {{< highlight yaml "linenos=inline, hl_lines=30-33 41-44, style=emacs" >}}
395
- apiVersion: v1
396
- items:
397
- - apiVersion: resource.k8s.io/v1beta2
398
- kind: ResourceClaim
399
- metadata:
400
- creationTimestamp: "2025-07-29T05:11:52Z"
376
+ {{< highlight yaml "linenos=inline, hl_lines=27-30 38-41, style=emacs" >}}
377
+ apiVersion: resource.k8s.io/v1
378
+ kind: ResourceClaim
379
+ metadata:
380
+ creationTimestamp: "2025-08-20T18:17:31Z"
401
381
finalizers:
402
382
- resource.kubernetes.io/delete-protection
403
383
name: some-gpu
404
384
namespace: dra-tutorial
405
- resourceVersion: "58357 "
406
- uid: 79e1e8d8-7e53-4362-aad1-eca97678339e
407
- spec:
385
+ resourceVersion: "2326 "
386
+ uid: d3e48dbf-40da-47c3-a7b9-f7d54d1051c3
387
+ spec:
408
388
devices:
409
- requests:
410
- - exactly:
411
- allocationMode: ExactCount
412
- count: 1
413
- deviceClassName: gpu.example.com
414
- selectors:
415
- - cel:
416
- expression: device.capacity[' gpu.example.com' ].memory.compareTo(quantity(' 10Gi' ))
389
+ requests:
390
+ - exactly:
391
+ allocationMode: ExactCount
392
+ count: 1
393
+ deviceClassName: gpu.example.com
394
+ selectors:
395
+ - cel:
396
+ expression: device.capacity[' gpu.example.com' ].memory.compareTo(quantity(' 10Gi' ))
417
397
>= 0
418
398
name: some-gpu
419
- status:
399
+ status:
420
400
allocation:
421
- devices:
401
+ devices:
422
402
results:
423
- - adminAccess: null
424
- device: gpu-4
425
- driver: gpu.example.com
426
- pool: kind-worker
427
- request: some-gpu
428
- nodeSelector:
403
+ - device: gpu-0
404
+ driver: gpu.example.com
405
+ pool: kind-worker
406
+ request: some-gpu
407
+ nodeSelector:
429
408
nodeSelectorTerms:
430
409
- matchFields:
431
- - key: metadata.name
410
+ - key: metadata.name
432
411
operator: In
433
412
values:
434
413
- kind-worker
435
414
reservedFor:
436
415
- name: pod0
437
- resource: pods
438
- uid: fa55b59b-d28d-4f7d-9e5b-ef4c8476dff5
439
- kind: List
440
- metadata:
441
- resourceVersion: ""
416
+ resource: pods
417
+ uid: c4dadf20-392a-474d-a47b-ab82080c8bd7
442
418
{{< /highlight >}}
443
419
444
420
1. To check how the driver handled device allocation, get the logs for the
@@ -450,8 +426,8 @@ variables to see how the Pods have been handled by the system.
450
426
451
427
The output is similar to this:
452
428
```
453
- I0729 05:11:52.679057 1 driver.go:84] NodePrepareResource is called: number of claims: 1
454
- I0729 05:11:52.684450 1 driver.go:112 ] Returning newly prepared devices for claim ' 79e1e8d8-7e53-4362-aad1-eca97678339e ' : [&Device{RequestNames: [some-gpu],PoolName: kind-worker,DeviceName: gpu-4,CDIDeviceIDs: [k8s.gpu.example.com/gpu=common k8s.gpu.example.com/gpu=79e1e8d8-7e53-4362-aad1-eca97678339e -gpu-4], }]
429
+ I0820 18:17:44.131324 1 driver.go:106] PrepareResourceClaims is called: number of claims: 1
430
+ I0820 18:17:44.135056 1 driver.go:133 ] Returning newly prepared devices for claim ' d3e48dbf-40da-47c3-a7b9-f7d54d1051c3 ' : [{ [some-gpu] kind-worker gpu-0 [k8s.gpu.example.com/gpu=common k8s.gpu.example.com/gpu=d3e48dbf-40da-47c3-a7b9-f7d54d1051c3 -gpu-0] }]
455
431
```
456
432
457
433
You have now successfully deployed a Pod that claims devices using DRA, verified
@@ -503,7 +479,7 @@ ResourceClaim has a `pending` state until it's referenced in a new Pod.
503
479
` ` `
504
480
The output is similar to this:
505
481
```
506
- I0729 05:13:02.144623 1 driver.go:117] NodeUnPrepareResource is called: number of claims: 1
482
+ I0820 18:22:15.629376 1 driver.go:138] UnprepareResourceClaims is called: number of claims: 1
507
483
```
508
484
509
485
You have now deleted a Pod that had a claim, and observed that the driver took
0 commit comments