-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcluster-template-rke2-dhcp.yaml
611 lines (611 loc) · 16.7 KB
/
cluster-template-rke2-dhcp.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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
apiVersion: v1
kind: Namespace
metadata:
name: ${NAMESPACE}
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
namespace: ${NAMESPACE}
name: ${CLUSTER_NAME}
labels:
${RANCHER_TURTLES_LABEL}
ccm: external
csi: external
cni: external
spec:
controlPlaneRef:
apiVersion: controlplane.cluster.x-k8s.io/v1alpha1
kind: RKE2ControlPlane
name: ${CLUSTER_NAME}-control-plane
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: HarvesterCluster
name: ${CLUSTER_NAME}-hv
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: HarvesterCluster
metadata:
name: ${CLUSTER_NAME}-hv
namespace: ${NAMESPACE}
spec:
targetNamespace: ${TARGET_HARVESTER_NAMESPACE}
loadBalancerConfig:
ipamType: dhcp
listeners:
- name: rke2-server
port: 9345
protocol: TCk
backendPort: 9345
server: ${HARVESTER_ENDPOINT}
identitySecret:
namespace: ${NAMESPACE}
name: hv-identity-secret
{UPDATE_CLOUD_PROVIDER:- updateCloudProviderConfig:
cloudConfigCredentialsSecretKey: cloud-config
cloudConfigCredentialsSecretName: cloud-config
manifestsConfigMapKey: harvester-cloud-provider-deploy.yaml
manifestsConfigMapName: harvester-csi-driver-addon
manifestsConfigMapNamespace: ${NAMESPACE}
}
---
apiVersion: v1
kind: Secret
metadata:
namespace: ${NAMESPACE}
name: hv-identity-secret
data:
kubeconfig: ${HARVESTER_KUBECONFIG_B64}
---
apiVersion: controlplane.cluster.x-k8s.io/v1alpha1
kind: RKE2ControlPlane
metadata:
namespace: ${NAMESPACE}
name: ${CLUSTER_NAME}-control-plane
spec:
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
agentConfig:
version: ${KUBERNETES_VERSION}+rke2r1
serverConfig:
cni: calico
cloudProviderName: external
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: HarvesterMachineTemplate
name: ${CLUSTER_NAME}-cp-machine
namespace: ${NAMESPACE}
---
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha1
kind: RKE2ConfigTemplate
metadata:
namespace: ${NAMESPACE}
name: ${CLUSTER_NAME}-worker
spec:
template:
spec:
agentConfig:
version: ${KUBERNETES_VERSION}+rke2r1
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
namespace: ${NAMESPACE}
name: ${CLUSTER_NAME}-workers
spec:
clusterName: ${CLUSTER_NAME}
replicas: ${WORKER_MACHINE_COUNT}
selector:
matchLabels:
cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME}
template:
spec:
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha1
kind: RKE2ConfigTemplate
name: ${CLUSTER_NAME}-worker
namespace: ${NAMESPACE}
clusterName: ${CLUSTER_NAME}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: HarvesterMachineTemplate
name: ${CLUSTER_NAME}-wk-machine
namespace: ${NAMESPACE}
version: ${KUBERNETES_VERSION}+rke2r1
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: HarvesterMachineTemplate
metadata:
namespace: ${NAMESPACE}
name: ${CLUSTER_NAME}-wk-machine
spec:
template:
spec:
cpu: 1
memory: 4Gi
sshUser: ubuntu
sshKeyPair: ${SSH_KEYPAIR}
networks:
- ${VM_NETWORK}
volumes:
- volumeType: image
imageName: ${VM_IMAGE_NAME}
volumeSize: ${VM_DISK_SIZE}
bootOrder: 0
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: HarvesterMachineTemplate
metadata:
namespace: ${NAMESPACE}
name: ${CLUSTER_NAME}-cp-machine
spec:
template:
spec:
cpu: 2
memory: 8Gi
sshUser: ubuntu
sshKeyPair: ${SSH_KEYPAIR}
networks:
- ${VM_NETWORK}
volumes:
- volumeType: image
imageName: ${VM_IMAGE_NAME}
volumeSize: ${VM_DISK_SIZE}
bootOrder: 0
---
apiVersion: addons.cluster.x-k8s.io/v1beta1
kind: ClusterResourceSet
metadata:
name: crs-harvester-ccm
namespace: ${NAMESPACE}
spec:
clusterSelector:
matchLabels:
ccm: external
resources:
- kind: ConfigMap
name: cloud-controller-manager-addon
strategy: ApplyOnce
---
apiVersion: addons.cluster.x-k8s.io/v1beta1
kind: ClusterResourceSet
metadata:
name: crs-harvester-csi
namespace: ${NAMESPACE}
spec:
clusterSelector:
matchLabels:
csi: external
resources:
- kind: ConfigMap
name: harvester-csi-driver-addon
strategy: ApplyOnce
---
apiVersion: addons.cluster.x-k8s.io/v1beta1
kind: ClusterResourceSet
metadata:
name: crs-calico-chart-config
namespace: ${NAMESPACE}
spec:
clusterSelector:
matchLabels:
cni: external
resources:
- kind: ConfigMap
name: calico-helm-config
strategy: ApplyOnce
---
apiVersion: v1
kind: ConfigMap
metadata:
name: cloud-controller-manager-addon
namespace: ${NAMESPACE}
data:
harvester-csi-deployment.yaml: |
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: harvester-csi-plugin
namespace: kube-system
spec:
selector:
matchLabels:
app: harvester-csi-plugin
template:
metadata:
labels:
app: harvester-csi-plugin
spec:
containers:
- args:
- --v=5
- --csi-address=$(ADDRESS)
- --kubelet-registration-path=/var/lib/kubelet/harvester-plugins/driver.harvesterhci.io/csi.sock
env:
- name: ADDRESS
value: /csi/csi.sock
image: longhornio/csi-node-driver-registrar:v2.12.0
lifecycle:
preStop:
exec:
command:
- /bin/sh
- -c
- rm -rf /registration/driver.harvesterhci.io-reg.sock
/csi//*
name: node-driver-registrar
securityContext:
privileged: true
volumeMounts:
- mountPath: /csi/
name: socket-dir
- mountPath: /registration
name: registration-dir
- args:
- --nodeid=$(NODE_ID)
- --endpoint=$(CSI_ENDPOINT)
- --kubeconfig=/etc/csi/cloud-config
env:
- name: NODE_ID
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: CSI_ENDPOINT
value: unix:///csi/csi.sock
image: rancher/harvester-csi-driver:v0.1.6
imagePullPolicy: Always
lifecycle:
preStop:
exec:
command:
- /bin/sh
- -c
- rm -f /csi//*
name: harvester-csi-plugin
securityContext:
allowPrivilegeEscalation: true
capabilities:
add:
- SYS_ADMIN
privileged: true
volumeMounts:
- name: cloud-config
mountPath: "/etc/csi"
readOnly: true
- mountPath: /var/lib/kubelet/plugins/kubernetes.io/csi
mountPropagation: Bidirectional
name: kubernetes-csi-dir
- mountPath: /csi/
name: socket-dir
- mountPath: /var/lib/kubelet/pods
mountPropagation: Bidirectional
name: pods-mount-dir
- mountPath: /dev
name: host-dev
- mountPath: /sys
name: host-sys
- mountPath: /rootfs
mountPropagation: Bidirectional
name: host
- mountPath: /lib/modules
name: lib-modules
readOnly: true
hostPID: true
serviceAccountName: harvester-csi
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/control-plane
operator: Exists
- effect: NoSchedule
key: kubevirt.io/drain
operator: Exists
volumes:
- name: cloud-config
secret:
secretName: cloud-config
- hostPath:
path: /var/lib/kubelet/plugins/kubernetes.io/csi
type: DirectoryOrCreate
name: kubernetes-csi-dir
- hostPath:
path: /var/lib/kubelet/plugins_registry
type: Directory
name: registration-dir
- hostPath:
path: /var/lib/kubelet/harvester-plugins/driver.harvesterhci.io
type: DirectoryOrCreate
name: socket-dir
- hostPath:
path: /var/lib/kubelet/pods
type: DirectoryOrCreate
name: pods-mount-dir
- hostPath:
path: /dev
name: host-dev
- hostPath:
path: /sys
name: host-sys
- hostPath:
path: /
name: host
- hostPath:
path: /lib/modules
name: lib-modules
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: harvester-csi
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: harvester-csi
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: harvester-csi
namespace: kube-system
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: csi-controller
namespace: kube-system
spec:
replicas: 1
selector:
matchLabels:
app: csi-controller
template:
metadata:
labels:
app: csi-controller
spec:
containers:
- args:
- --v=5
- --csi-address=$(ADDRESS)
- --timeout=2m5s
- --leader-election
- --leader-election-namespace=$(POD_NAMESPACE)
env:
- name: ADDRESS
value: /csi/csi.sock
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
image: longhornio/csi-resizer:v1.12.0
name: csi-resizer
volumeMounts:
- mountPath: /csi/
name: socket-dir
- args:
- --v=5
- --csi-address=$(ADDRESS)
- --timeout=2m5s
- --leader-election
- --leader-election-namespace=$(POD_NAMESPACE)
env:
- name: ADDRESS
value: /csi/csi.sock
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
image: longhornio/csi-provisioner:v5.1.0
name: csi-provisioner
volumeMounts:
- mountPath: /csi/
name: socket-dir
- args:
- --v=5
- --csi-address=$(ADDRESS)
- --timeout=2m5s
- --leader-election
- --leader-election-namespace=$(POD_NAMESPACE)
env:
- name: ADDRESS
value: /csi/csi.sock
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
image: longhornio/csi-attacher:v4.7.0
name: csi-attacher
volumeMounts:
- mountPath: /csi/
name: socket-dir
serviceAccountName: harvester-csi
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/control-plane
operator: Exists
- effect: NoSchedule
key: kubevirt.io/drain
operator: Exists
volumes:
- hostPath:
path: /var/lib/kubelet/harvester-plugins/driver.harvesterhci.io
type: DirectoryOrCreate
name: socket-dir
---
apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
name: driver.harvesterhci.io
spec:
attachRequired: true
fsGroupPolicy: ReadWriteOnceWithFSType
podInfoOnMount: true
volumeLifecycleModes:
- Persistent
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: harvester
annotation:
storageclass.kubernetes.io/is-default-class: "true"
allowVolumeExpansion: true
provisioner: driver.harvesterhci.io
reclaimPolicy: Delete
volumeBindingMode: Immediate
---
apiVersion: v1
kind: ConfigMap
metadata:
name: harvester-csi-driver-addon
namespace: ${NAMESPACE}
data:
harvester-cloud-provider-deploy.yaml: |
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/component: cloud-provider
app.kubernetes.io/name: harvester-cloud-provider
name: harvester-cloud-provider
namespace: kube-system
spec:
replicas: 2
selector:
matchLabels:
app.kubernetes.io/component: cloud-provider
app.kubernetes.io/name: harvester-cloud-provider
template:
metadata:
labels:
app.kubernetes.io/component: cloud-provider
app.kubernetes.io/name: harvester-cloud-provider
spec:
containers:
- args:
- --cloud-config=/etc/kubernetes/cloud-config
command:
- harvester-cloud-provider
image: rancher/harvester-cloud-provider:v0.2.0
imagePullPolicy: Always
name: harvester-cloud-provider
resources: {}
volumeMounts:
- mountPath: /etc/kubernetes
name: cloud-config
serviceAccountName: harvester-cloud-controller-manager
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/control-plane
operator: Exists
- effect: NoSchedule
key: node.cloudprovider.kubernetes.io/uninitialized
operator: Equal
value: "true"
volumes:
- name: cloud-config
secret:
secretName: cloud-config
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: harvester-cloud-controller-manager
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: harvester-cloud-controller-manager
rules:
- apiGroups:
- ""
resources:
- services
- nodes
- events
verbs:
- get
- list
- watch
- create
- update
- patch
- apiGroups:
- ""
resources:
- services/status
verbs:
- update
- patch
- apiGroups:
- ""
resources:
- nodes/status
verbs:
- patch
- update
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- get
- create
- update
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: harvester-cloud-controller-manager
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: harvester-cloud-controller-manager
subjects:
- kind: ServiceAccount
name: harvester-cloud-controller-manager
namespace: kube-system
---
apiVersion: v1
kind: Secret
metadata:
name: cloud-config
namespace: kube-system
type: Opaque
data:
cloud-config: ${CLOUD_CONFIG_KUBECONFIG_B64}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: calico-helm-config
namespace: ${NAMESPACE}
data:
calico-helm-config.yaml: |
apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
name: rke2-calico
namespace: kube-system
spec:
valuesContent: |-
installation:
controlPlaneTolerations:
- key: "node-role.kubernetes.io/control-plane"
operator: Exists
effect: NoSchedule
- key: "node-role.kubernetes.io/etcd"
operator: Exists
effect: NoExecute
- key: "node.cloudprovider.kubernetes.io/uninitialized"
operator: Equal
value: "true"
effect: NoSchedule