1
- # Example Resource Driver for Dynamic Resource Allocation (DRA)
1
+ # Example Resource Driver for Dynamic Resource Allocation (DRA)
2
2
3
3
This repository contains an example resource driver for use with the [ Dynamic
4
4
Resource Allocation
@@ -30,23 +30,22 @@ The procedure below has been tested and verified on both Linux and Mac.
30
30
* [ kubectl v1.18+] ( https://kubernetes.io/docs/reference/kubectl/ )
31
31
32
32
### Demo
33
- We start by first cloning this repository and ` cd ` ing into its ` demo `
34
- subdirectory. All of the scripts and example Pod specs used in this demo are
35
- contained here, so take a moment to browse through the various files and see
36
- what's available:
33
+ We start by first cloning this repository and ` cd ` ing into it. All of the
34
+ scripts and example Pod specs used in this demo are contained here, so take a
35
+ moment to browse through the various files and see what's available:
37
36
```
38
37
git clone https://github.com/kubernetes-sigs/dra-example-driver.git
39
- cd dra-example-driver/demo
38
+ cd dra-example-driver
40
39
```
41
40
42
41
From here we will build the image for the example resource driver:
43
42
``` bash
44
- ./build-driver.sh
43
+ ./demo/ build-driver.sh
45
44
```
46
45
47
46
And create a ` kind ` cluster to run it in:
48
47
``` bash
49
- ./create-cluster.sh
48
+ ./demo/ create-cluster.sh
50
49
```
51
50
52
51
Once the cluster has been created successfully, double check everything is
@@ -67,13 +66,13 @@ kube-system kube-scheduler-dra-example-driver-cluster-control-plane
67
66
local-path-storage local-path-provisioner-7dbf974f64-9jmc7 1/1 Running 0 1m
68
67
```
69
68
70
- And then install the example resource driver via ` helm ` :
69
+ And then install the example resource driver via ` helm ` .
71
70
``` bash
72
71
helm upgrade -i \
73
72
--create-namespace \
74
73
--namespace dra-example-driver \
75
74
dra-example-driver \
76
- ../ deployments/helm/dra-example-driver
75
+ deployments/helm/dra-example-driver
77
76
```
78
77
79
78
Double check the driver components have come up successfully:
@@ -85,43 +84,46 @@ dra-example-driver-kubeletplugin-qwmbl 1/1 Running 0 1m
85
84
```
86
85
87
86
And show the initial state of available GPU devices on the worker node:
88
- ``` console
89
- $ kubectl describe -n dra-example-driver nas/dra-example-driver-cluster-worker
90
- ...
91
- Spec:
92
- Allocatable Devices:
93
- Gpu:
94
- Product Name: LATEST-GPU-MODEL
95
- Uuid: GPU-9ede7e32-5825-a11b-fa3d-bab6d47e0243
96
- Gpu:
97
- Product Name: LATEST-GPU-MODEL
98
- Uuid: GPU-e7b42cb1-4fd8-91b2-bc77-352a0c1f5747
99
- Gpu:
100
- Product Name: LATEST-GPU-MODEL
101
- Uuid: GPU-f11773a1-5bfb-e48b-3d98-1beb5baaf08e
102
- Gpu:
103
- Product Name: LATEST-GPU-MODEL
104
- Uuid: GPU-0159f35e-99ee-b2b5-74f1-9d18df3f22ac
105
- Gpu:
106
- Product Name: LATEST-GPU-MODEL
107
- Uuid: GPU-657bd2e7-f5c2-a7f2-fbaa-0d1cdc32f81b
108
- Gpu:
109
- Product Name: LATEST-GPU-MODEL
110
- Uuid: GPU-18db0e85-99e9-c746-8531-ffeb86328b39
111
- Gpu:
112
- Product Name: LATEST-GPU-MODEL
113
- Uuid: GPU-93d37703-997c-c46f-a531-755e3e0dc2ac
114
- Gpu:
115
- Product Name: LATEST-GPU-MODEL
116
- Uuid: GPU-ee3e4b55-fcda-44b8-0605-64b7a9967744
117
- ...
87
+ ```
88
+ $ kubectl get resourceslice -o yaml
89
+ apiVersion: v1
90
+ items:
91
+ - apiVersion: resource.k8s.io/v1alpha2
92
+ driverName: gpu.resource.example.com
93
+ kind: ResourceSlice
94
+ metadata:
95
+ creationTimestamp: "2024-04-17T13:45:44Z"
96
+ generateName: dra-example-driver-cluster-worker-gpu.resource.example.com-
97
+ name: dra-example-driver-cluster-worker-gpu.resource.example.comxktph
98
+ ownerReferences:
99
+ - apiVersion: v1
100
+ controller: true
101
+ kind: Node
102
+ name: dra-example-driver-cluster-worker
103
+ uid: 4dc7c3b2-d99c-492b-8ede-37d435e56b2d
104
+ resourceVersion: "1189"
105
+ uid: 61c965b5-54a9-40ee-88a1-c52a814fa624
106
+ namedResources:
107
+ instances:
108
+ - name: gpu-0159f35e-99ee-b2b5-74f1-9d18df3f22ac
109
+ - name: gpu-657bd2e7-f5c2-a7f2-fbaa-0d1cdc32f81b
110
+ - name: gpu-18db0e85-99e9-c746-8531-ffeb86328b39
111
+ - name: gpu-93d37703-997c-c46f-a531-755e3e0dc2ac
112
+ - name: gpu-ee3e4b55-fcda-44b8-0605-64b7a9967744
113
+ - name: gpu-9ede7e32-5825-a11b-fa3d-bab6d47e0243
114
+ - name: gpu-e7b42cb1-4fd8-91b2-bc77-352a0c1f5747
115
+ - name: gpu-f11773a1-5bfb-e48b-3d98-1beb5baaf08e
116
+ nodeName: dra-example-driver-cluster-worker
117
+ kind: List
118
+ metadata:
119
+ resourceVersion: ""
118
120
```
119
121
120
122
Next, deploy four example apps that demonstrate how ` ResourceClaim ` s,
121
123
` ResourceClaimTemplate ` s, and custom ` ClaimParameter ` objects can be used to
122
124
request access to resources in various ways:
123
125
``` bash
124
- kubectl apply --filename=gpu-test{1,2,3,4}.yaml
126
+ kubectl apply --filename=demo/ gpu-test{1,2,3,4}.yaml
125
127
```
126
128
127
129
And verify that they are coming up successfully:
@@ -196,47 +198,13 @@ You can use the UUIDs of the GPUs set in these environment variables to verify
196
198
that they were handed out in a way consistent with the semantics shown in the
197
199
figure above.
198
200
199
- Likewise, looking at the ` ClaimAllocations ` section of the
200
- ` NodeAllocationState ` object on the worker node will show which GPUs have been
201
- allocated to a given ` ResourceClaim ` by the resource driver:
202
- ``` console
203
- $ kubectl describe -n dra-example-driver nas/dra-example-driver-cluster-worker
204
- ...
205
- Spec:
206
- ...
207
- Prepared Claims:
208
- 132ccf41-2ec6-4751-a0e5-94f3635a679a:
209
- Gpu:
210
- Devices:
211
- Uuid: GPU-0159f35e-99ee-b2b5-74f1-9d18df3f22ac
212
- 330d73e1-b5bb-40be-bc4b-2b940f1bf34f:
213
- Gpu:
214
- Devices:
215
- Uuid: GPU-18db0e85-99e9-c746-8531-ffeb86328b39
216
- d764a8d4-4481-4bc6-959b-27695f434953:
217
- Gpu:
218
- Devices:
219
- Uuid: GPU-ee3e4b55-fcda-44b8-0605-64b7a9967744
220
- Uuid: GPU-e7b42cb1-4fd8-91b2-bc77-352a0c1f5747
221
- Uuid: GPU-9ede7e32-5825-a11b-fa3d-bab6d47e0243
222
- Uuid: GPU-f11773a1-5bfb-e48b-3d98-1beb5baaf08e
223
- e811664d-e487-4eb7-9ac7-678c837cbb32:
224
- Gpu:
225
- Devices:
226
- Uuid: GPU-657bd2e7-f5c2-a7f2-fbaa-0d1cdc32f81b
227
- ef07764f-8dc0-4c4b-a99f-328711702e63:
228
- Gpu:
229
- Devices:
230
- Uuid: GPU-93d37703-997c-c46f-a531-755e3e0dc2ac
231
- ```
232
-
233
201
Once you have verified everything is running correctly, delete all of the
234
202
example apps:
235
203
``` bash
236
- kubectl delete --wait=false --filename=gpu-test{1,2,3,4}.yaml
204
+ kubectl delete --wait=false --filename=demo/ gpu-test{1,2,3,4}.yaml
237
205
```
238
206
239
- Wait for them to terminate:
207
+ And wait for them to terminate:
240
208
``` console
241
209
$ kubectl get pod -A
242
210
NAMESPACE NAME READY STATUS RESTARTS AGE
@@ -250,44 +218,10 @@ gpu-test4 pod0 1/1 Terminating 0 31m
250
218
...
251
219
```
252
220
253
- And show that the ` ClaimAllocations ` section of the ` NodeAllocationState `
254
- object on the worker node is now back to its initial state:
255
- ``` console
256
- $ kubectl describe -n dra-example-driver nas/dra-example-driver-cluster-worker
257
- ...
258
- Spec:
259
- Allocatable Devices:
260
- Gpu:
261
- Product Name: LATEST-GPU-MODEL
262
- Uuid: GPU-657bd2e7-f5c2-a7f2-fbaa-0d1cdc32f81b
263
- Gpu:
264
- Product Name: LATEST-GPU-MODEL
265
- Uuid: GPU-18db0e85-99e9-c746-8531-ffeb86328b39
266
- Gpu:
267
- Product Name: LATEST-GPU-MODEL
268
- Uuid: GPU-93d37703-997c-c46f-a531-755e3e0dc2ac
269
- Gpu:
270
- Product Name: LATEST-GPU-MODEL
271
- Uuid: GPU-ee3e4b55-fcda-44b8-0605-64b7a9967744
272
- Gpu:
273
- Product Name: LATEST-GPU-MODEL
274
- Uuid: GPU-9ede7e32-5825-a11b-fa3d-bab6d47e0243
275
- Gpu:
276
- Product Name: LATEST-GPU-MODEL
277
- Uuid: GPU-e7b42cb1-4fd8-91b2-bc77-352a0c1f5747
278
- Gpu:
279
- Product Name: LATEST-GPU-MODEL
280
- Uuid: GPU-f11773a1-5bfb-e48b-3d98-1beb5baaf08e
281
- Gpu:
282
- Product Name: LATEST-GPU-MODEL
283
- Uuid: GPU-0159f35e-99ee-b2b5-74f1-9d18df3f22ac
284
- ...
285
- ```
286
-
287
221
Finally, you can run the following to cleanup your environment and delete the
288
222
` kind ` cluster started previously:
289
223
``` bash
290
- ./delete-cluster.sh
224
+ ./demo/ delete-cluster.sh
291
225
```
292
226
293
227
## Anatomy of a DRA resource driver
0 commit comments