Skip to content

Commit 57c2fa2

Browse files
authored
Merge pull request #51716 from lauralorenz/51179-tutorial-dra-driver-install-and-observe
Tutorial page: Using DRA and installing drivers
2 parents cd78b2b + 098eb14 commit 57c2fa2

File tree

9 files changed

+698
-0
lines changed

9 files changed

+698
-0
lines changed

content/en/docs/tutorials/cluster-management/install-use-dra.md

Lines changed: 540 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: dra-example-driver-role
5+
rules:
6+
- apiGroups: ["resource.k8s.io"]
7+
resources: ["resourceclaims"]
8+
verbs: ["get"]
9+
- apiGroups: [""]
10+
resources: ["nodes"]
11+
verbs: ["get"]
12+
- apiGroups: ["resource.k8s.io"]
13+
resources: ["resourceslices"]
14+
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: dra-example-driver-role-binding
5+
subjects:
6+
- kind: ServiceAccount
7+
name: dra-example-driver-service-account
8+
namespace: dra-tutorial
9+
roleRef:
10+
kind: ClusterRole
11+
name: dra-example-driver-role
12+
apiGroup: rbac.authorization.k8s.io
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: dra-example-driver-kubeletplugin
5+
namespace: dra-tutorial
6+
labels:
7+
app.kubernetes.io/name: dra-example-driver
8+
spec:
9+
selector:
10+
matchLabels:
11+
app.kubernetes.io/name: dra-example-driver
12+
updateStrategy:
13+
type: RollingUpdate
14+
template:
15+
metadata:
16+
labels:
17+
app.kubernetes.io/name: dra-example-driver
18+
spec:
19+
priorityClassName: dra-driver-high-priority
20+
serviceAccountName: dra-example-driver-service-account
21+
securityContext:
22+
{}
23+
containers:
24+
- name: plugin
25+
securityContext:
26+
privileged: true
27+
image: registry.k8s.io/dra-example-driver/dra-example-driver:v0.1.0
28+
imagePullPolicy: IfNotPresent
29+
command: ["dra-example-kubeletplugin"]
30+
resources:
31+
{}
32+
# Production drivers should always implement a liveness probe
33+
# For the tutorial we simply omit it
34+
# livenessProbe:
35+
# grpc:
36+
# port: 51515
37+
# service: liveness
38+
# failureThreshold: 3
39+
# periodSeconds: 10
40+
env:
41+
- name: CDI_ROOT
42+
value: /var/run/cdi
43+
- name: KUBELET_REGISTRAR_DIRECTORY_PATH
44+
value: "/var/lib/kubelet/plugins_registry"
45+
- name: KUBELET_PLUGINS_DIRECTORY_PATH
46+
value: "/var/lib/kubelet/plugins"
47+
- name: NODE_NAME
48+
valueFrom:
49+
fieldRef:
50+
fieldPath: spec.nodeName
51+
- name: NAMESPACE
52+
valueFrom:
53+
fieldRef:
54+
fieldPath: metadata.namespace
55+
# Simulated number of devices the example driver will pretend to have.
56+
- name: NUM_DEVICES
57+
value: "9"
58+
- name: HEALTHCHECK_PORT
59+
value: "51515"
60+
volumeMounts:
61+
- name: plugins-registry
62+
mountPath: "/var/lib/kubelet/plugins_registry"
63+
- name: plugins
64+
mountPath: "/var/lib/kubelet/plugins"
65+
- name: cdi
66+
mountPath: /var/run/cdi
67+
volumes:
68+
- name: plugins-registry
69+
hostPath:
70+
path: "/var/lib/kubelet/plugins_registry"
71+
- name: plugins
72+
hostPath:
73+
path: "/var/lib/kubelet/plugins"
74+
- name: cdi
75+
hostPath:
76+
path: /var/run/cdi
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: resource.k8s.io/v1beta1
2+
kind: DeviceClass
3+
metadata:
4+
name: gpu.example.com
5+
spec:
6+
selectors:
7+
- cel:
8+
expression: "device.driver == 'gpu.example.com'"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: pod0
5+
namespace: dra-tutorial
6+
labels:
7+
app: pod
8+
spec:
9+
containers:
10+
- name: ctr0
11+
image: ubuntu:24.04
12+
command: ["bash", "-c"]
13+
args: ["export; trap 'exit 0' TERM; sleep 9999 & wait"]
14+
resources:
15+
claims:
16+
- name: gpu
17+
resourceClaims:
18+
- name: gpu
19+
resourceClaimName: some-gpu
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: resource.k8s.io/v1beta2
2+
kind: ResourceClaim
3+
metadata:
4+
name: some-gpu
5+
namespace: dra-tutorial
6+
spec:
7+
devices:
8+
requests:
9+
- name: some-gpu
10+
exactly:
11+
deviceClassName: gpu.example.com
12+
selectors:
13+
- cel:
14+
expression: "device.capacity['gpu.example.com'].memory.compareTo(quantity('10Gi')) >= 0"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: scheduling.k8s.io/v1
2+
kind: PriorityClass
3+
metadata:
4+
name: dra-driver-high-priority
5+
value: 1000000
6+
globalDefault: false
7+
description: "This priority class should be used for DRA driver pods only."
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: dra-example-driver-service-account
5+
namespace: dra-tutorial
6+
labels:
7+
app.kubernetes.io/name: dra-example-driver
8+
app.kubernetes.io/instance: dra-example-driver

0 commit comments

Comments
 (0)