-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.yaml
More file actions
235 lines (233 loc) · 6.38 KB
/
Copy pathinstall.yaml
File metadata and controls
235 lines (233 loc) · 6.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: fluxbind
rules:
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
- apiGroups:
- "resource.k8s.io"
resources:
- resourceslices
verbs:
- list
- watch
- create
- update
- delete
- apiGroups:
- "resource.k8s.io"
resources:
- resourceclaims
- deviceclasses
- resourceslices
- resourceclaims/status
verbs:
- get
- create
- update
- patch
- delete
- update
- list
- apiGroups:
- ""
resources:
- pods
verbs:
- get
- list
- watch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: fluxbind
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: fluxbind
subjects:
- kind: ServiceAccount
name: fluxbind
namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: fluxbind
namespace: kube-system
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluxbind
namespace: kube-system
labels:
tier: node
app: fluxbind
k8s-app: fluxbind
spec:
selector:
matchLabels:
app: fluxbind
template:
metadata:
labels:
tier: node
app: fluxbind
k8s-app: fluxbind
spec:
hostNetwork: true
tolerations:
- operator: Exists
effect: NoSchedule
serviceAccountName: fluxbind
hostPID: true
initContainers:
- name: enable-nri-and-cdi
image: busybox:stable
volumeMounts:
- mountPath: /etc
name: etc
securityContext:
privileged: true
# Taken from dracpu
command:
- /bin/sh
- -c
- |
set -o errexit
set -o pipefail
set -o nounset
set -x
CONFIG_CHANGED=false
CONTAINERD_CONFIG_PATH="/etc/containerd/config.toml"
# --- Enable CDI ---
if grep -q '^\s*enable_cdi\s*=\s*true' "$CONTAINERD_CONFIG_PATH"; then
echo "containerd config already has CDI enabled; taking no action"
else
echo "containerd config does not have CDI enabled, thus enabling it";
sed -i '/\[plugins\."io\.containerd\.grpc\.v1\.cri"\]/a \ enable_cdi = true' "$CONTAINERD_CONFIG_PATH"
CONFIG_CHANGED=true
fi
# --- CDI Spec Dirs Configuration ---
if grep -q '^\s*cdi_spec_dirs\s*=' "$CONTAINERD_CONFIG_PATH"; then
echo "containerd config already configures cdi_spec_dirs; taking no action"
else
echo "containerd config does not configure cdi_spec_dirs, thus setting it";
sed -i '/\[plugins\."io\.containerd\.grpc\.v1\.cri"\]/a \ cdi_spec_dirs = ["/etc/cdi", "/var/run/cdi"]' "$CONTAINERD_CONFIG_PATH"
CONFIG_CHANGED=true
fi
# --- Enable NRI ---
if grep -q "io.containerd.nri.v1.nri" "$CONTAINERD_CONFIG_PATH"
then
echo "containerd config contains NRI reference already; taking no action"
else
echo "containerd config does not mention NRI, thus enabling it";
printf '%s\n' "[plugins.\"io.containerd.nri.v1.nri\"]" " disable = false" " disable_connections = false" " plugin_config_path = \"/etc/nri/conf.d\"" " plugin_path = \"/opt/nri/plugins\"" " plugin_registration_timeout = \"5s\"" " plugin_request_timeout = \"5s\"" " socket_path = \"/var/run/nri/nri.sock\"" >> "$CONTAINERD_CONFIG_PATH"
CONFIG_CHANGED=true
fi
mkdir -p /etc/nri/conf.d
# Create a config file that tells containerd where to find your plugin's socket.
cat <<EOF > /etc/nri/conf.d/fluxbind.conf
# NRI v1 plugin configuration for fluxbind
idx = 10
addr = "/var/run/nri/nri.sock"
EOF
echo "Created NRI v1 plugin configuration for fluxbind."
if [ "$CONFIG_CHANGED" = true ]; then
echo "restarting containerd"
nsenter -t 1 -m -u -i -n -p -- systemctl restart containerd
fi
containers:
- name: nri-sidecar
image: ghcr.io/converged-computing/fluxbind-dra-driver:nri
imagePullPolicy: Never
securityContext:
privileged: true
volumeMounts:
- name: nri-plugin
mountPath: /var/run/nri
- name: fluxbind-shared
mountPath: /run/fluxbind
args:
- "--name=fluxbind"
- "--idx=01"
- name: fluxbind
args:
- fluxbind-dra-driver
- --v=4
image: ghcr.io/converged-computing/fluxbind-dra-driver
imagePullPolicy: Never
# imagePullPolicy: Always
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
resources:
requests:
cpu: "100m"
memory: "50Mi"
securityContext:
capabilities:
add: ["NET_ADMIN", "SYS_ADMIN"]
volumeMounts:
- name: device-plugin
mountPath: /var/lib/kubelet/plugins
- name: plugin-registry
mountPath: /var/lib/kubelet/plugins_registry
- name: nri-plugin
mountPath: /var/run/nri
- name: fluxbind-shared
mountPath: /run/fluxbind
- name: cdi-dir
mountPath: /var/run/cdi
volumes:
- name: device-plugin
hostPath:
path: /var/lib/kubelet/plugins
- name: plugin-registry
hostPath:
path: /var/lib/kubelet/plugins_registry
- name: nri-plugin
hostPath:
path: /var/run/nri
- name: fluxbind-shared
hostPath:
path: /run/fluxbind
- name: netns
hostPath:
path: /var/run/netns
- name: infiniband
hostPath:
path: /dev/infiniband
- name: etc
hostPath:
path: /etc
- name: cdi-dir
hostPath:
path: /var/run/cdi
type: DirectoryOrCreate
---
apiVersion: resource.k8s.io/v1
kind: DeviceClass
metadata:
name: shape
spec:
selectors:
- cel:
expression: device.driver == "fluxbind"