Skip to content

Commit 6e99295

Browse files
authored
Merge pull request #47 from kubernetes-sigs/structured-parameters
Add support for structured parameters
2 parents e5778a2 + 49c8d0a commit 6e99295

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+639
-2633
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ vendor/
44

55
./dra-example-controller
66
./dra-example-kubeletplugin
7-
./set-nas-status

README.md

+46-112
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Example Resource Driver for Dynamic Resource Allocation (DRA)
1+
# Example Resource Driver for Dynamic Resource Allocation (DRA)
22

33
This repository contains an example resource driver for use with the [Dynamic
44
Resource Allocation
@@ -30,23 +30,22 @@ The procedure below has been tested and verified on both Linux and Mac.
3030
* [kubectl v1.18+](https://kubernetes.io/docs/reference/kubectl/)
3131

3232
### 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:
3736
```
3837
git clone https://github.com/kubernetes-sigs/dra-example-driver.git
39-
cd dra-example-driver/demo
38+
cd dra-example-driver
4039
```
4140

4241
From here we will build the image for the example resource driver:
4342
```bash
44-
./build-driver.sh
43+
./demo/build-driver.sh
4544
```
4645

4746
And create a `kind` cluster to run it in:
4847
```bash
49-
./create-cluster.sh
48+
./demo/create-cluster.sh
5049
```
5150

5251
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
6766
local-path-storage local-path-provisioner-7dbf974f64-9jmc7 1/1 Running 0 1m
6867
```
6968

70-
And then install the example resource driver via `helm`:
69+
And then install the example resource driver via `helm`.
7170
```bash
7271
helm upgrade -i \
7372
--create-namespace \
7473
--namespace dra-example-driver \
7574
dra-example-driver \
76-
../deployments/helm/dra-example-driver
75+
deployments/helm/dra-example-driver
7776
```
7877

7978
Double check the driver components have come up successfully:
@@ -85,43 +84,46 @@ dra-example-driver-kubeletplugin-qwmbl 1/1 Running 0 1m
8584
```
8685

8786
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: ""
118120
```
119121

120122
Next, deploy four example apps that demonstrate how `ResourceClaim`s,
121123
`ResourceClaimTemplate`s, and custom `ClaimParameter` objects can be used to
122124
request access to resources in various ways:
123125
```bash
124-
kubectl apply --filename=gpu-test{1,2,3,4}.yaml
126+
kubectl apply --filename=demo/gpu-test{1,2,3,4}.yaml
125127
```
126128

127129
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
196198
that they were handed out in a way consistent with the semantics shown in the
197199
figure above.
198200

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-
233201
Once you have verified everything is running correctly, delete all of the
234202
example apps:
235203
```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
237205
```
238206

239-
Wait for them to terminate:
207+
And wait for them to terminate:
240208
```console
241209
$ kubectl get pod -A
242210
NAMESPACE NAME READY STATUS RESTARTS AGE
@@ -250,44 +218,10 @@ gpu-test4 pod0 1/1 Terminating 0 31m
250218
...
251219
```
252220

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-
287221
Finally, you can run the following to cleanup your environment and delete the
288222
`kind` cluster started previously:
289223
```bash
290-
./delete-cluster.sh
224+
./demo/delete-cluster.sh
291225
```
292226

293227
## Anatomy of a DRA resource driver

api/example.com/resource/gpu/nas/v1alpha1/api.go

-53
This file was deleted.

api/example.com/resource/gpu/nas/v1alpha1/client/client.go

-101
This file was deleted.

0 commit comments

Comments
 (0)