Skip to content

Commit da4fb39

Browse files
committed
Add kustomization for using GPU plugin with fake devices
Change GPU plugin NFD init container to run-time container: * To work around kustomize inability to enforce correct init container order * This is more likely how things will work once NFD drops support for hooks: kubernetes-sigs/node-feature-discovery#856 Signed-off-by: Eero Tamminen <[email protected]>
1 parent 85563ec commit da4fb39

6 files changed

+136
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: intel-gpu-plugin
5+
spec:
6+
template:
7+
spec:
8+
containers:
9+
- name: intel-gpu-nfd
10+
# convert generated sysfs content to NFD feature labels file
11+
image: intel/intel-gpu-initcontainer:devel
12+
imagePullPolicy: IfNotPresent
13+
securityContext:
14+
readOnlyRootFilesystem: true
15+
allowPrivilegeEscalation: false
16+
capabilities:
17+
drop: [ "ALL" ]
18+
volumeMounts:
19+
- name: nfd-features
20+
mountPath: /nfd
21+
readOnly: false
22+
workingDir: /usr/local/bin/gpu-sw
23+
# needed until GPU plugin drops NFD hook usage due to:
24+
# https://github.com/kubernetes-sigs/node-feature-discovery/issues/856
25+
command: ["sh", "-c", "while true; do ./intel-gpu-nfdhook | tee /nfd/fake-gpu; sleep 99999; done"]
26+
volumes:
27+
- name: nfd-features
28+
hostPath:
29+
path: /etc/kubernetes/node-feature-discovery/features.d/
30+
type: DirectoryOrCreate
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: intel-gpu-plugin
5+
spec:
6+
template:
7+
spec:
8+
initContainers:
9+
- name: intel-gpu-initcontainer
10+
$patch: delete
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: intel-gpu-plugin
5+
spec:
6+
template:
7+
spec:
8+
initContainers:
9+
- name: fakedev-generator
10+
# container runtime prevents writing to /sys & /dev,
11+
# so volumes need to be mounted elsewhere
12+
volumeMounts:
13+
- name: devfs
14+
mountPath: /tmp/fakedev/dev
15+
readOnly: false
16+
- name: sysfs
17+
mountPath: /tmp/fakedev/sys
18+
readOnly: false
19+
# files are generated under CWD
20+
workingDir: /tmp/fakedev
21+
containers:
22+
- name: intel-gpu-nfd
23+
# expects sysfs here
24+
volumeMounts:
25+
- name: sysfs
26+
mountPath: /host-sys
27+
readOnly: true
28+
- name: intel-gpu-plugin
29+
args: [
30+
"-prefix=/tmp/fakedev",
31+
"-shared-dev-num=2",
32+
"-enable-monitoring",
33+
"-resource-manager"
34+
]
35+
# devfs host & container paths must match for everything to work
36+
volumeMounts:
37+
- name: devfs
38+
mountPath: /tmp/fakedev/dev
39+
readOnly: true
40+
- name: sysfs
41+
mountPath: /tmp/fakedev/sys
42+
readOnly: true
43+
volumes:
44+
- name: devfs
45+
hostPath:
46+
path: /tmp/fakedev/dev
47+
type: DirectoryOrCreate
48+
- name: sysfs
49+
emptyDir: {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Info": "8x 4 GiB DG1 [Iris Xe MAX Graphics] GPUs",
3+
"DevCount": 8,
4+
"DevMemSize": 4294967296,
5+
"Capabilities": {
6+
"platform": "fake_DG1"
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: intel-gpu-plugin
5+
spec:
6+
template:
7+
spec:
8+
volumes:
9+
- name: fake-conf
10+
configMap:
11+
name: fakedev-config
12+
initContainers:
13+
- name: fakedev-generator
14+
image: intel/intel-gpu-fakedev:devel
15+
securityContext:
16+
runAsUser: 0
17+
readOnlyRootFilesystem: false
18+
allowPrivilegeEscalation: false
19+
volumeMounts:
20+
- name: fake-conf
21+
mountPath: /config
22+
readOnly: true
23+
# generate fake sysfs / devfs files for GPU plugin based on config
24+
command: ["/generator", "-json", "/config/fakedev.json", "-verbose"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
bases:
4+
- ../fractional_resources
5+
configMapGenerator:
6+
- name: fakedev-config
7+
files:
8+
- fakedev-config.json
9+
patches:
10+
- fake-device-volumes.yaml
11+
- generate-fake-devices.yaml
12+
# NFD feature file changes is obsolete after GPU plugin moves away from NFD hooks
13+
# https://github.com/kubernetes-sigs/node-feature-discovery/issues/856
14+
- del-intel-gpu-initcontainer.yaml
15+
- add-nfd-feature-file.yaml

0 commit comments

Comments
 (0)