This repository has been archived by the owner on Dec 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.yaml
433 lines (418 loc) · 13.7 KB
/
deploy.yaml
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
# WINRM_PASSWORD="$(python3 -m keyring get hyperv01.homelab.somemissing.info administrator | tr -d '\n' | base64)" envsubst < deploy.yaml | kubectl apply -f -
---
apiVersion: v1
kind: Namespace
metadata:
name: hyperv-csi-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: hyperv-csi
namespace: hyperv-csi-system
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: external-provisioner-runner
rules:
# The following rule should be uncommented for plugins that require secrets
# for provisioning.
# - apiGroups: [""]
# resources: ["secrets"]
# verbs: ["get", "list"]
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["events"]
verbs: ["list", "watch", "create", "update", "patch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshots"]
verbs: ["get", "list"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotcontents"]
verbs: ["get", "list"]
- apiGroups: ["storage.k8s.io"]
resources: ["csinodes"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch"]
# Access to volumeattachments is only needed when the CSI driver
# has the PUBLISH_UNPUBLISH_VOLUME controller capability.
# In that case, external-provisioner will watch volumeattachments
# to determine when it is safe to delete a volume.
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattachments"]
verbs: ["get", "list", "watch"]
# (Alpha) Access to referencegrants is only needed when the CSI driver
# has the CrossNamespaceVolumeDataSource controller capability.
# In that case, external-provisioner requires "get", "list", "watch"
# permissions for "referencegrants" on "gateway.networking.k8s.io".
#- apiGroups: ["gateway.networking.k8s.io"]
# resources: ["referencegrants"]
# verbs: ["get", "list", "watch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-provisioner-role
subjects:
- kind: ServiceAccount
name: hyperv-csi
namespace: hyperv-csi-system
roleRef:
kind: ClusterRole
name: external-provisioner-runner
apiGroup: rbac.authorization.k8s.io
---
# Provisioner must be able to work with endpoints in current namespace
# if (and only if) leadership election is enabled
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: external-provisioner-cfg
namespace: hyperv-csi-system
rules:
# Only one of the following rules for endpoints or leases is required based on
# what is set for `--leader-election-type`. Endpoints are deprecated in favor of Leases.
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get", "watch", "list", "delete", "update", "create"]
# Permissions for CSIStorageCapacity are only needed enabling the publishing
# of storage capacity information.
- apiGroups: ["storage.k8s.io"]
resources: ["csistoragecapacities"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
# The GET permissions below are needed for walking up the ownership chain
# for CSIStorageCapacity. They are sufficient for deployment via
# StatefulSet (only needs to get Pod) and Deployment (needs to get
# Pod and then ReplicaSet to find the Deployment).
- apiGroups: [""]
resources: ["pods"]
verbs: ["get"]
- apiGroups: ["apps"]
resources: ["replicasets"]
verbs: ["get"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-provisioner-role-cfg
namespace: hyperv-csi-system
subjects:
- kind: ServiceAccount
name: hyperv-csi
namespace: hyperv-csi-system
roleRef:
kind: Role
name: external-provisioner-cfg
apiGroup: rbac.authorization.k8s.io
---
# Attacher must be able to work with PVs, CSINodes and VolumeAttachments
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: external-attacher-runner
rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "patch"]
- apiGroups: ["storage.k8s.io"]
resources: ["csinodes"]
verbs: ["get", "list", "watch"]
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattachments"]
verbs: ["get", "list", "watch", "patch"]
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattachments/status"]
verbs: ["patch"]
#Secret permission is optional.
#Enable it if you need value from secret.
#For example, you have key `csi.storage.k8s.io/controller-publish-secret-name` in StorageClass.parameters
#see https://kubernetes-csi.github.io/docs/secrets-and-credentials.html
# - apiGroups: [""]
# resources: ["secrets"]
# verbs: ["get", "list"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-attacher-role
subjects:
- kind: ServiceAccount
name: hyperv-csi
namespace: hyperv-csi-system
roleRef:
kind: ClusterRole
name: external-attacher-runner
apiGroup: rbac.authorization.k8s.io
---
# Attacher must be able to work with configmaps or leases in the current namespace
# if (and only if) leadership election is enabled
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: external-attacher-cfg
namespace: hyperv-csi-system
rules:
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get", "watch", "list", "delete", "update", "create"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-attacher-role-cfg
namespace: hyperv-csi-system
subjects:
- kind: ServiceAccount
name: hyperv-csi
namespace: hyperv-csi-system
roleRef:
kind: Role
name: external-attacher-cfg
apiGroup: rbac.authorization.k8s.io
---
apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
name: hyperv-csi.nijave.github.com
spec: {}
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: hyperv
annotations:
"storageclass.kubernetes.io/is-default-class": "true"
provisioner: hyperv-csi.nijave.github.com
parameters:
type: hyperv
reclaimPolicy: Retain
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: hyperv-xfs
provisioner: hyperv-csi.nijave.github.com
parameters:
type: hyperv-xfs
csi.storage.k8s.io/fstype: xfs
reclaimPolicy: Retain
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: hyperv-csi
namespace: hyperv-csi-system
spec:
replicas: 1
selector:
matchLabels:
app: hyperv-csi
template:
metadata:
labels:
app: hyperv-csi
spec:
serviceAccount: hyperv-csi
containers:
- name: csi-provisioner
image: registry.k8s.io/sig-storage/csi-provisioner:v3.5.0
args:
- "--csi-address=$(ADDRESS)"
- "--leader-election"
- "--http-endpoint=:8080"
- "--v=5"
env:
- name: ADDRESS
value: /run/csi/hyperv-csi.sock
imagePullPolicy: "IfNotPresent"
volumeMounts:
- name: socket-dir
mountPath: /run/csi
ports:
- containerPort: 8080
name: http-endpoint
protocol: TCP
livenessProbe:
failureThreshold: 1
httpGet:
path: /healthz/leader-election
port: http-endpoint
initialDelaySeconds: 10
timeoutSeconds: 10
periodSeconds: 20
- name: csi-attacher
image: registry.k8s.io/sig-storage/csi-attacher:v3.5.0
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
- "--leader-election"
- "--http-endpoint=:8081"
- "--v=5"
env:
- name: MY_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: ADDRESS
value: /run/csi/hyperv-csi.sock
imagePullPolicy: "IfNotPresent"
volumeMounts:
- name: socket-dir
mountPath: /run/csi
ports:
- containerPort: 8081
name: http-endpoint
protocol: TCP
livenessProbe:
failureThreshold: 1
httpGet:
path: /healthz/leader-election
port: http-endpoint
initialDelaySeconds: 10
timeoutSeconds: 10
periodSeconds: 20
- name: hyperv-csi
image: registry.apps.nickv.me/hyperv-csi:latest
args:
- "-v=8"
# command: [sleep, infinity]
imagePullPolicy: Always
env:
- name: WINRM_HOST
value: "https://hyperv01.homelab.somemissing.info:5986"
- name: WINRM_USER
value: administrator
- name: WINRM_PASSWORD
valueFrom:
secretKeyRef:
name: hyperv-csi
key: WINRM_PASSWORD
- name: WINRM_CA_FILE_PATH
value: /var/run/secrets/winrm.pem
- name: CSI_ADDRESS
value: /run/csi/hyperv-csi.sock
volumeMounts:
- name: socket-dir
mountPath: /run/csi
- name: secrets
readOnly: true
mountPath: /var/run/secrets/winrm.pem
subPath: WINRM_CA_FILE
volumes:
- name: socket-dir
emptyDir:
- name: secrets
secret:
secretName: hyperv-csi
---
kind: Secret
apiVersion: v1
metadata:
name: hyperv-csi
namespace: hyperv-csi-system
type: Opaque
data:
WINRM_PASSWORD: "${WINRM_PASSWORD}"
WINRM_CA_F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nVUQU5CZ2txCmhraUc5dzBCQVFzRkFBT0NBUUVBYlg5YWxYSTJNYS90VG42ZDZIZjkvZGlBZmZjL3VYT3IraHFpdXRMelhwWDcKWjc2RHZ5azJQc2dYcUZCMWFQSmd1eU81V2hRRU5URjhsWUZnK09JaWVaU0w4aXZCNDB6WVp5dGtBaW9qNzB4UwpvUHNpRE1Qemp2RGVtdE5Qd09za2UvQjEweG8rRU55Q3FKOGplak5GK29MNHI0c2xxT3RnOHZOUjI1YkN5S2JnCkZlRWdQcjBUMVpPWi80ZVRyOVpsMkRCOE5QMUJiVGJ4TXV4VnNRaXZHQzJ6WXg5Mjd5dWhlTGlLd0kramZQZmcKbjR0S3FZVHg3dWg0UUIrNjdKQVJLTGJEWXR4YzVCa1d2bjBLY3E1aHBScVZSS1NuckxrSUFIaGtPYXIzZDBzSApPNU1oRm1TQnBzYlFySWF2NUhEMFBLa3ZCUUJqRTM2L09MQzljb3F1bHc9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
---
kind: DaemonSet
apiVersion: apps/v1
metadata:
labels:
app: hyperv-csi-node
name: hyperv-csi-node
namespace: hyperv-csi-system
spec:
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 10
selector:
matchLabels:
app: hyperv-csi-node
template:
metadata:
labels:
app: hyperv-csi-node
spec:
containers:
- name: node-driver-registrar
args:
- --csi-address=$(ADDRESS)
- --kubelet-registration-path=$(REGISTRATION_PATH)
- --v=5
env:
- name: ADDRESS
value: /run/csi/csi.sock
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: REGISTRATION_PATH
value: /var/lib/kubelet/plugins/hyperv-csi.nijave.github.com/csi.sock
image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.8.0
imagePullPolicy: Always
securityContext:
privileged: true
volumeMounts:
- name: plugin-dir
mountPath: /run/csi
- name: registration-dir
mountPath: /registration
- name: hyperv-csi-node
image: registry.apps.nickv.me/hyperv-csi:latest
imagePullPolicy: Always
args:
- -grpc-service=driver
env:
- name: CSI_ADDRESS
value: /run/csi/csi.sock
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
securityContext:
privileged: true
volumeMounts:
- name: device-dir
mountPath: /dev
- name: host-root
mountPath: /host
- name: kubelet-dir
mountPath: /var/lib/kubelet
mountPropagation: Bidirectional
- name: plugin-dir
mountPath: /run/csi
hostNetwork: true
volumes:
- name: device-dir
hostPath:
path: /dev
type: Directory
- name: host-root
hostPath:
path: /
type: Directory
- name: kubelet-dir
hostPath:
path: /var/lib/kubelet
type: Directory
- name: plugin-dir
hostPath:
path: /var/lib/kubelet/plugins/hyperv-csi.nijave.github.com
type: DirectoryOrCreate
- name: registration-dir
hostPath:
path: /var/lib/kubelet/plugins_registry
type: Directory