-
Notifications
You must be signed in to change notification settings - Fork 13
/
cluster-autoscaler-vanilla.yaml
531 lines (531 loc) · 13.5 KB
/
cluster-autoscaler-vanilla.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
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
k8s-addon: cluster-autoscaler.addons.k8s.io
k8s-app: cluster-autoscaler
name: cluster-autoscaler
namespace: kube-system
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: cluster-autoscaler
labels:
k8s-addon: cluster-autoscaler.addons.k8s.io
k8s-app: cluster-autoscaler
rules:
- verbs:
- create
- patch
apiGroups:
- ""
resources:
- events
- endpoints
- verbs:
- create
apiGroups:
- ""
resources:
- pods/eviction
- verbs:
- update
apiGroups:
- ""
resources:
- nodes/status
- verbs:
- update
apiGroups:
- ""
resources:
- pods/status
- verbs:
- get
- update
- delete
apiGroups:
- ""
resources:
- endpoints
resourceNames:
- cluster-autoscaler
- vsphere-autoscaler
- verbs:
- watch
- list
- get
- update
- delete
- patch
apiGroups:
- ""
resources:
- nodes
- verbs:
- watch
- list
- get
- update
apiGroups:
- ""
resources:
- pods
- namespaces
- services
- replicationcontrollers
- persistentvolumeclaims
- persistentvolumes
- verbs:
- watch
- list
- get
apiGroups:
- extensions
resources:
- replicasets
- daemonsets
- verbs:
- watch
- list
apiGroups:
- policy
resources:
- poddisruptionbudgets
- verbs:
- watch
- list
- get
- delete
apiGroups:
- apps
resources:
- statefulsets
- replicasets
- daemonsets
- verbs:
- get
- list
- watch
apiGroups:
- storage.k8s.io
resources:
- storageclasses
- csinodes
- verbs:
- watch
- list
- get
apiGroups:
- batch
resources:
- jobs
- cronjobs
- verbs:
- create
apiGroups:
- coordination.k8s.io
resources:
- leases
- verbs:
- get
- update
apiGroups:
- coordination.k8s.io
resources:
- leases
resourceNames:
- cluster-autoscaler
- verbs:
- list
- get
- update
- watch
apiGroups:
- storage.k8s.io
resources:
- csistoragecapacities
- csidrivers
- verbs:
- list
- get
- update
- watch
- delete
- patch
apiGroups:
- nodemanager.aldunelabs.com
resources:
- "*"
- verbs:
- list
- get
- update
- watch
- delete
- create
apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: cluster-autoscaler
namespace: kube-system
labels:
k8s-addon: cluster-autoscaler.addons.k8s.io
k8s-app: cluster-autoscaler
rules:
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["create"]
- apiGroups: [""]
resources: ["configmaps"]
resourceNames: ["cluster-autoscaler-status"]
verbs: ["delete", "get", "update"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: cluster-autoscaler
labels:
k8s-addon: cluster-autoscaler.addons.k8s.io
k8s-app: cluster-autoscaler
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-autoscaler
subjects:
- kind: ServiceAccount
name: cluster-autoscaler
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: cluster-autoscaler
namespace: kube-system
labels:
k8s-addon: cluster-autoscaler.addons.k8s.io
k8s-app: cluster-autoscaler
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: cluster-autoscaler
subjects:
- kind: ServiceAccount
name: cluster-autoscaler
namespace: kube-system
---
apiVersion: v1
kind: ConfigMap
metadata:
name: config-cluster-autoscaler
namespace: kube-system
data:
cloud-config: |-
address: unix:/var/run/cluster-autoscaler/vmware.sock
key: "/etc/ssl/client-cert/tls.key"
cert: "/etc/ssl/client-cert/tls.crt"
cacert: "/etc/ssl/client-cert/ca.crt"
kubernetes-vmware-autoscaler.json: |
{
"distribution": "kubeadm",
"use-external-etcd": false,
"src-etcd-ssl-dir": "/etc/etcd/ssl",
"dst-etcd-ssl-dir": "/etc/kubernetes/pki/etcd",
"kubernetes-pki-srcdir": "/etc/kubernetes/pki",
"kubernetes-pki-dstdir": "/etc/kubernetes/pki",
"network": "unix",
"listen": "/var/run/cluster-autoscaler/vmware.sock",
"cert-private-key": "/etc/ssl/client-cert/tls.key",
"cert-public-key": "/etc/ssl/client-cert/tls.crt",
"cert-ca": "/etc/ssl/client-cert/ca.crt",
"secret": "vmware",
"minNode": 0,
"maxNode": 9,
"maxNode-per-cycle": 2,
"node-name-prefix": "autoscaled",
"managed-name-prefix": "managed",
"controlplane-name-prefix": "master",
"nodePrice": 0,
"podPrice": 0,
"image": "jammy-kubernetes-cni-flannel-v1.28.4-containerd-amd64",
"optionals": {
"pricing": false,
"getAvailableMachineTypes": false,
"newNodeGroup": false,
"templateNodeInfo": false,
"createNodeGroup": false,
"deleteNodeGroup": false
},
"kubeadm": {
"address": "192.168.1.120:6443",
"token": "h1g55p.hm4rg52ymloax182",
"ca": "sha256:c7a86a7a9a03a628b59207f4f3b3e038ebd03260f3ad5ba28f364d513b01f542",
"extras-args": [
"--ignore-preflight-errors=All"
]
},
"default-machine": "large",
"machines": {
"tiny": {
"memsize": 2048,
"vcpus": 2,
"disksize": 10240
},
"small": {
"memsize": 4096,
"vcpus": 2,
"disksize": 20480
},
"medium": {
"memsize": 4096,
"vcpus": 4,
"disksize": 20480
},
"large": {
"memsize": 8192,
"vcpus": 4,
"disksize": 51200
},
"xlarge": {
"memsize": 16384,
"vcpus": 4,
"disksize": 102400
},
"2xlarge": {
"memsize": 16384,
"vcpus": 8,
"disksize": 102400
},
"4xlarge": {
"memsize": 32768,
"vcpus": 8,
"disksize": 102400
}
},
"node-labels": [
"topology.kubernetes.io/region=home",
"topology.kubernetes.io/zone=office",
"topology.csi.vmware.com/k8s-region=home",
"topology.csi.vmware.com/k8s-zone=office"
],
"cloud-init": {
"package_update": false,
"package_upgrade": false,
"runcmd": [
"echo 1 > /sys/block/sda/device/rescan",
"growpart /dev/sda 1",
"resize2fs /dev/sda1",
"echo '192.168.1.120 vmware-ca-k8s-masterkube vmware-ca-k8s-masterkube.acme.com' >> /etc/hosts"
]
},
"ssh-infos": {
"user": "kubernetes",
"ssh-private-key": "/root/.ssh/id_rsa"
},
"autoscaling-options": {
"scaleDownUtilizationThreshold": 0.5,
"scaleDownGpuUtilizationThreshold": 0.5,
"scaleDownUnneededTime": "1m",
"scaleDownUnreadyTime": "1m",
},
"vmware": {
"vmware-ca-k8s": {
"url": "https://[email protected]:[email protected]/sdk",
"uid": "[email protected]",
"password": "mySecret",
"insecure": true,
"dc": "DC01",
"datastore": "datastore1",
"resource-pool": "ACME/Resources/FR",
"vmFolder": "HOME",
"timeout": 300,
"template-name": "jammy-kubernetes-cni-flannel-v1.28.4-containerd-amd64",
"template": false,
"linked": false,
"customization": "",
"network": {
"domain": "acme.com",
"dns": {
"search": [
"acme.com"
],
"nameserver": [
"10.0.0.1"
]
},
"interfaces": [
{
"primary": false,
"exists": true,
"network": "VM Network",
"adapter": "vmxnet3",
"mac-address": "generate",
"nic": "eth0",
"dhcp": true,
"use-dhcp-routes": true,
"routes": [
{
"to": "172.30.0.0/16",
"via": "10.0.0.5",
"metric": 500
}
]
},
{
"primary": true,
"exists": true,
"network": "VM Private",
"adapter": "vmxnet3",
"mac-address": "generate",
"nic": "eth1",
"dhcp": true,
"use-dhcp-routes": false,
"address": "192.168.1.124",
"gateway": "10.0.0.1",
"netmask": "255.255.255.0",
"routes": []
}
]
}
}
}
}
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: cluster-autoscaler
namespace: kube-system
labels:
k8s-app: cluster-autoscaler
spec:
replicas: 1
selector:
matchLabels:
k8s-app: cluster-autoscaler
template:
metadata:
labels:
k8s-app: cluster-autoscaler
spec:
volumes:
- name: cluster-socket
emptyDir: {}
- name: config-cluster-autoscaler
configMap:
name: config-cluster-autoscaler
defaultMode: 420
- name: ssl-certs
hostPath:
path: /etc/ssl/certs/ca-certificates.crt
- name: autoscaler-ssh-keys
secret:
secretName: autoscaler-ssh-keys
defaultMode: 384
- name: etcd-ssl
secret:
secretName: etcd-ssl
defaultMode: 384
- name: kubernetes-pki
configMap:
name: kubernetes-pki
defaultMode: 420
- name: cluster-autoscaler-grpc-client-cert
secret:
secretName: cluster-autoscaler-grpc-client-cert
defaultMode: 0400
initContainers:
- name: cluster-autoscaler-init
image: busybox
command:
- /bin/sh
- "-c"
- rm -f /var/run/cluster-autoscaler/vmware.sock
volumeMounts:
- name: cluster-socket
mountPath: /var/run/cluster-autoscaler
containers:
- name: vsphere-autoscaler
image: fred78290/vsphere-autoscaler:v1.28.4
command:
- /usr/local/bin/vsphere-autoscaler
- "--no-use-external-etcd"
- "--src-etcd-ssl-dir=/etc/etcd/ssl"
- "--dst-etcd-ssl-dir=/etc/etcd/ssl"
- "--config=/etc/cluster/kubernetes-vmware-autoscaler.json"
- "--save=/var/run/cluster-autoscaler/vmware-autoscaler-state.json"
- "--log-level=info"
resources:
limits:
cpu: 100m
memory: 300Mi
requests:
cpu: 100m
memory: 300Mi
volumeMounts:
- name: cluster-socket
mountPath: /var/run/cluster-autoscaler
- name: config-cluster-autoscaler
mountPath: /etc/cluster
- name: autoscaler-ssh-keys
mountPath: /root/.ssh
- name: etcd-ssl
mountPath: /etc/etcd/ssl
- name: kubernetes-pki
mountPath: /etc/kubernetes/pki
- name: cluster-autoscaler-grpc-client-cert
mountPath: "/etc/ssl/client-cert"
- name: cluster-autoscaler
image: k8s.gcr.io/autoscaling/cluster-autoscaler:v1.28.4
command:
- ./cluster-autoscaler
- "--v=1"
- "--stderrthreshold=info"
- "--cloud-provider=externalgrpc"
- "--cloud-config=/etc/cluster/cloud-config"
- "--max-nodes-total=9"
- "--cores-total=0:16"
- "--memory-total=0:48"
- "--node-autoprovisioning-enabled"
- "--max-autoprovisioned-node-group-count=1"
- "--scale-down-enabled=true"
- "--scale-down-delay-after-add=1m"
- "--scale-down-delay-after-delete=1m"
- "--scale-down-delay-after-failure=1m"
- "--scale-down-unneeded-time=1m"
- "--scale-down-unready-time=1m"
- "--unremovable-node-recheck-timeout=1m"
resources:
limits:
cpu: 100m
memory: 300Mi
requests:
cpu: 100m
memory: 300Mi
volumeMounts:
- name: cluster-socket
mountPath: /var/run/cluster-autoscaler
- name: ssl-certs
readOnly: true
mountPath: /etc/ssl/certs/ca-certificates.crt
- name: config-cluster-autoscaler
readOnly: true
mountPath: /etc/cluster
- name: cluster-autoscaler-grpc-client-cert
mountPath: "/etc/ssl/client-cert"
restartPolicy: Always
dnsPolicy: ClusterFirst
serviceAccountName: cluster-autoscaler
serviceAccount: cluster-autoscaler
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
- key: node-role.kubernetes.io/control-plane
effect: NoSchedule