-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathpod.gotpl.yaml
More file actions
442 lines (427 loc) · 14.7 KB
/
pod.gotpl.yaml
File metadata and controls
442 lines (427 loc) · 14.7 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
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
apiVersion: v1
kind: Pod
metadata:
name: etcd
namespace: openshift-etcd
annotations:
kubectl.kubernetes.io/default-container: etcd
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
labels:
app: etcd
k8s-app: etcd
etcd: "true"
revision: "REVISION"
spec:
initContainers:
- name: setup
image: {{.Image}}
imagePullPolicy: IfNotPresent
terminationMessagePolicy: FallbackToLogsOnError
command:
- /bin/sh
- -c
- |
#!/bin/sh
echo -n "Fixing etcd log permissions."
mkdir -p /var/log/etcd && chmod 0600 /var/log/etcd
echo -n "Fixing etcd auto backup permissions."
mkdir -p /var/lib/etcd-auto-backup && chmod 0600 /var/lib/etcd-auto-backup
securityContext:
privileged: true
readOnlyRootFilesystem: true
resources:
requests:
memory: 50Mi
cpu: 5m
volumeMounts:
- mountPath: /var/log/etcd
name: log-dir
- mountPath: /var/lib/etcd-auto-backup
name: etcd-auto-backup-dir
- name: etcd-ensure-env-vars
image: {{.Image}}
imagePullPolicy: IfNotPresent
terminationMessagePolicy: FallbackToLogsOnError
command:
- /bin/sh
- -c
- |
#!/bin/sh
set -euo pipefail
: "${NODE_NODE_ENVVAR_NAME_ETCD_URL_HOST?not set}"
: "${NODE_NODE_ENVVAR_NAME_ETCD_NAME?not set}"
: "${NODE_NODE_ENVVAR_NAME_IP?not set}"
# check for ipv4 addresses as well as ipv6 addresses with extra square brackets
if [[ "${NODE_NODE_ENVVAR_NAME_IP}" != "${NODE_IP}" && "${NODE_NODE_ENVVAR_NAME_IP}" != "[${NODE_IP}]" ]]; then
# echo the error message to stderr
echo "Expected node IP to be ${NODE_IP} got ${NODE_NODE_ENVVAR_NAME_IP}" >&2
exit 1
fi
# check for ipv4 addresses as well as ipv6 addresses with extra square brackets
if [[ "${NODE_NODE_ENVVAR_NAME_ETCD_URL_HOST}" != "${NODE_IP}" && "${NODE_NODE_ENVVAR_NAME_ETCD_URL_HOST}" != "[${NODE_IP}]" ]]; then
# echo the error message to stderr
echo "Expected etcd url host to be ${NODE_IP} got ${NODE_NODE_ENVVAR_NAME_ETCD_URL_HOST}" >&2
exit 1
fi
resources:
requests:
memory: 60Mi
cpu: 10m
securityContext:
privileged: true
readOnlyRootFilesystem: true
env:
{{ range $i, $k := .EnvVars -}}
- name: {{ $k.Name | quote }}
value: {{ $k.Value | quote }}
{{ end -}}
- name: NODE_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: etcd-resources-copy
image: {{.Image}}
imagePullPolicy: IfNotPresent
terminationMessagePolicy: FallbackToLogsOnError
command:
- /bin/sh
- -c
- |
#!/bin/sh
set -euo pipefail
rm -f $(grep -l '^### Created by cluster-etcd-operator' /usr/local/bin/*)
cp -p /etc/kubernetes/static-pod-certs/configmaps/etcd-scripts/*.sh /usr/local/bin
resources:
requests:
memory: 60Mi
cpu: 10m
securityContext:
privileged: true
readOnlyRootFilesystem: true
volumeMounts:
- mountPath: /etc/kubernetes/static-pod-resources
name: resource-dir
- mountPath: /etc/kubernetes/static-pod-certs
name: cert-dir
- mountPath: /usr/local/bin
name: usr-local-bin
- mountPath: /tmp
name: tmp-dir
containers:
# The etcdctl container should always be first. It is intended to be used
# to open a remote shell via `oc rsh` that is ready to run `etcdctl`.
- name: etcdctl
image: {{.Image}}
imagePullPolicy: IfNotPresent
terminationMessagePolicy: FallbackToLogsOnError
command:
- "/bin/bash"
- "-c"
- "trap TERM INT; sleep infinity & wait"
resources:
requests:
memory: 60Mi
cpu: 10m
volumeMounts:
- mountPath: /etc/kubernetes/manifests
name: static-pod-dir
- mountPath: /etc/kubernetes/static-pod-resources
name: resource-dir
- mountPath: /etc/kubernetes/static-pod-certs
name: cert-dir
- mountPath: /var/lib/etcd/
name: data-dir
- mountPath: /tmp
name: tmp-dir
securityContext:
readOnlyRootFilesystem: true
env:
{{ range .EnvVars -}}
- name: {{ .Name | quote }}
value: {{ .Value | quote }}
{{ end -}}
- name: "ETCD_STATIC_POD_VERSION"
value: "REVISION"
{{ if .EnableEtcdContainer }}
- name: etcd
image: {{.Image}}
imagePullPolicy: IfNotPresent
terminationMessagePolicy: FallbackToLogsOnError
command:
- /bin/sh
- -c
- |
#!/bin/sh
set -euo pipefail
etcdctl member list || true
# this has a non-zero return code if the command is non-zero. If you use an export first, it doesn't and you
# will succeed when you should fail.
ETCD_INITIAL_CLUSTER=$(discover-etcd-initial-cluster \
--cacert=/etc/kubernetes/static-pod-certs/configmaps/etcd-all-bundles/server-ca-bundle.crt \
--cert=/etc/kubernetes/static-pod-certs/secrets/etcd-all-certs/etcd-peer-NODE_NAME.crt \
--key=/etc/kubernetes/static-pod-certs/secrets/etcd-all-certs/etcd-peer-NODE_NAME.key \
--endpoints=${ALL_ETCD_ENDPOINTS} \
--data-dir=/var/lib/etcd \
--target-peer-url-host=${NODE_NODE_ENVVAR_NAME_ETCD_URL_HOST} \
--target-name=NODE_NAME)
export ETCD_INITIAL_CLUSTER
# we cannot use the "normal" port conflict initcontainer because when we upgrade, the existing static pod will never yield,
# so we do the detection in etcd container itself.
echo -n "Waiting for ports 2379, 2380 and 9978 to be released."
time while [ -n "$(ss -Htan '( sport = 2379 or sport = 2380 or sport = 9978 )')" ]; do
echo -n "."
sleep 1
done
export ETCD_NAME=${NODE_NODE_ENVVAR_NAME_ETCD_NAME}
env | grep ETCD | grep -v NODE
set -x
# See https://etcd.io/docs/v3.4.0/tuning/ for why we use ionice
exec nice -n -19 ionice -c2 -n0 etcd \
--logger=zap \
--log-level={{.LogLevel}} \
--feature-gates=InitialCorruptCheck=true \
--initial-advertise-peer-urls=https://${NODE_NODE_ENVVAR_NAME_IP}:2380 \
--cert-file=/etc/kubernetes/static-pod-certs/secrets/etcd-all-certs/etcd-serving-NODE_NAME.crt \
--key-file=/etc/kubernetes/static-pod-certs/secrets/etcd-all-certs/etcd-serving-NODE_NAME.key \
--trusted-ca-file=/etc/kubernetes/static-pod-certs/configmaps/etcd-all-bundles/server-ca-bundle.crt \
--client-cert-auth=true \
--peer-cert-file=/etc/kubernetes/static-pod-certs/secrets/etcd-all-certs/etcd-peer-NODE_NAME.crt \
--peer-key-file=/etc/kubernetes/static-pod-certs/secrets/etcd-all-certs/etcd-peer-NODE_NAME.key \
--peer-trusted-ca-file=/etc/kubernetes/static-pod-certs/configmaps/etcd-all-bundles/server-ca-bundle.crt \
--peer-client-cert-auth=true \
--advertise-client-urls=https://${NODE_NODE_ENVVAR_NAME_IP}:2379 \
--listen-client-urls=https://{{.ListenAddress}}:2379 \
--listen-peer-urls=https://{{.ListenAddress}}:2380 \
--metrics=extensive \
--listen-metrics-urls=https://{{.ListenAddress}}:9978 || mv /etc/kubernetes/etcd-backup-dir/etcd-member.yaml /etc/kubernetes/manifests
ports:
- containerPort: 2379
name: etcd
protocol: TCP
- containerPort: 2380
name: etcd-peer
protocol: TCP
- containerPort: 9978
name: etcd-metrics
protocol: TCP
env:
{{- range .EnvVars }}
- name: {{ .Name | quote }}
value: {{ .Value | quote }}
{{- end }}
- name: "ETCD_STATIC_POD_VERSION"
value: "REVISION"
resources:
requests:
memory: 600Mi
cpu: 300m
readinessProbe:
httpGet:
port: 9980
path: readyz
scheme: HTTPS
timeoutSeconds: {{ .ReadinessProbe.TimeoutSeconds }}
periodSeconds: {{ .ReadinessProbe.PeriodSeconds }}
successThreshold: {{ .ReadinessProbe.SuccessThreshold }}
failureThreshold: {{ .ReadinessProbe.FailureThreshold }}
initialDelaySeconds: {{ .ReadinessProbe.InitialDelaySeconds }}
livenessProbe:
httpGet:
path: healthz
port: 9980
scheme: HTTPS
timeoutSeconds: {{ .LivenessProbe.TimeoutSeconds }}
periodSeconds: {{ .LivenessProbe.PeriodSeconds }}
successThreshold: {{ .LivenessProbe.SuccessThreshold }}
failureThreshold: {{ .LivenessProbe.FailureThreshold }}
initialDelaySeconds: {{ .LivenessProbe.InitialDelaySeconds }}
startupProbe:
httpGet:
port: 9980
path: readyz
scheme: HTTPS
timeoutSeconds: {{ .StartupProbe.TimeoutSeconds }}
periodSeconds: {{ .StartupProbe.PeriodSeconds }}
successThreshold: {{ .StartupProbe.SuccessThreshold }}
failureThreshold: {{ .StartupProbe.FailureThreshold }}
initialDelaySeconds: {{ .StartupProbe.InitialDelaySeconds }}
securityContext:
privileged: true
readOnlyRootFilesystem: true
volumeMounts:
- mountPath: /etc/kubernetes/manifests
name: static-pod-dir
- mountPath: /etc/kubernetes/static-pod-resources
name: resource-dir
- mountPath: /etc/kubernetes/static-pod-certs
name: cert-dir
- mountPath: /var/lib/etcd/
name: data-dir
- mountPath: /tmp
name: tmp-dir
{{ end }}
- name: etcd-metrics
image: {{.Image}}
imagePullPolicy: IfNotPresent
terminationMessagePolicy: FallbackToLogsOnError
command:
- /bin/sh
- -c
- |
#!/bin/sh
set -euo pipefail
export ETCD_NAME=${NODE_NODE_ENVVAR_NAME_ETCD_NAME}
exec nice -n -18 etcd grpc-proxy start \
--endpoints https://${NODE_NODE_ENVVAR_NAME_ETCD_URL_HOST}:9978 \
--metrics-addr https://{{.ListenAddress}}:9979 \
--listen-addr {{.LocalhostAddress}}:9977 \
--advertise-client-url "" \
--key /etc/kubernetes/static-pod-certs/secrets/etcd-all-certs/etcd-peer-NODE_NAME.key \
--key-file /etc/kubernetes/static-pod-certs/secrets/etcd-all-certs/etcd-serving-metrics-NODE_NAME.key \
--cert /etc/kubernetes/static-pod-certs/secrets/etcd-all-certs/etcd-peer-NODE_NAME.crt \
--cert-file /etc/kubernetes/static-pod-certs/secrets/etcd-all-certs/etcd-serving-metrics-NODE_NAME.crt \
--cacert /etc/kubernetes/static-pod-certs/configmaps/etcd-all-bundles/server-ca-bundle.crt \
--trusted-ca-file /etc/kubernetes/static-pod-certs/configmaps/etcd-all-bundles/metrics-ca-bundle.crt \
{{- if .CipherSuites }}
--listen-cipher-suites {{ .CipherSuites }} \
{{ end -}}
--tls-min-version $(ETCD_TLS_MIN_VERSION)
ports:
- containerPort: 9979
name: proxy-metrics
protocol: TCP
env:
{{- range .EnvVars }}
- name: {{ .Name | quote }}
value: {{ .Value | quote }}
{{ end -}}
- name: "ETCD_STATIC_POD_VERSION"
value: "REVISION"
resources:
requests:
memory: 200Mi
cpu: 40m
securityContext:
privileged: true
readOnlyRootFilesystem: true
volumeMounts:
- mountPath: /etc/kubernetes/static-pod-resources
name: resource-dir
- mountPath: /etc/kubernetes/static-pod-certs
name: cert-dir
- mountPath: /var/lib/etcd/
name: data-dir
- mountPath: /tmp
name: tmp-dir
- name: etcd-readyz
image: {{.OperatorImage}}
imagePullPolicy: IfNotPresent
terminationMessagePolicy: FallbackToLogsOnError
command:
- /bin/sh
- -c
- |
#!/bin/sh
set -euo pipefail
exec nice -n -18 cluster-etcd-operator readyz \
--target=https://localhost:2379 \
--listen-port=9980 \
--serving-cert-file=/etc/kubernetes/static-pod-certs/secrets/etcd-all-certs/etcd-serving-NODE_NAME.crt \
--serving-key-file=/etc/kubernetes/static-pod-certs/secrets/etcd-all-certs/etcd-serving-NODE_NAME.key \
--client-cert-file=$(ETCDCTL_CERT) \
--client-key-file=$(ETCDCTL_KEY) \
--client-cacert-file=$(ETCDCTL_CACERT) \
{{- if .CipherSuites }}
--listen-cipher-suites {{ .CipherSuites }} \
{{ end -}}
--listen-tls-min-version=$(ETCD_TLS_MIN_VERSION)
securityContext:
privileged: true
readOnlyRootFilesystem: true
ports:
- containerPort: 9980
name: readyz
protocol: TCP
resources:
requests:
memory: 50Mi
cpu: 10m
env:
{{ range .EnvVars -}}
- name: {{ .Name | quote }}
value: {{ .Value | quote }}
{{ end -}}
volumeMounts:
- mountPath: /var/log/etcd/
name: log-dir
- mountPath: /etc/kubernetes/static-pod-certs
name: cert-dir
- mountPath: /tmp
name: tmp-dir
- name: etcd-rev
image: {{.OperatorImage}}
imagePullPolicy: IfNotPresent
terminationMessagePolicy: FallbackToLogsOnError
command:
- /bin/sh
- -c
- |
#!/bin/sh
set -euo pipefail
cluster-etcd-operator rev \
--endpoints=$(ALL_ETCD_ENDPOINTS) \
--client-cert-file=$(ETCDCTL_CERT) \
--client-key-file=$(ETCDCTL_KEY) \
--client-cacert-file=$(ETCDCTL_CACERT)
securityContext:
privileged: true
readOnlyRootFilesystem: true
resources:
requests:
memory: 50Mi
cpu: 10m
env:
{{ range .EnvVars -}}
- name: {{ .Name | quote }}
value: {{ .Value | quote }}
{{ end -}}
volumeMounts:
- mountPath: /var/lib/etcd
name: data-dir
- mountPath: /etc/kubernetes/static-pod-certs
name: cert-dir
- mountPath: /tmp
name: tmp-dir
hostNetwork: true
priority: 2000001000
priorityClassName: system-node-critical
tolerations:
- operator: "Exists"
volumes:
- hostPath:
path: /etc/kubernetes/manifests
name: static-pod-dir
- hostPath:
path: /etc/kubernetes/static-pod-resources/etcd-pod-REVISION
name: resource-dir
- hostPath:
path: /etc/kubernetes/static-pod-resources/etcd-certs
name: cert-dir
- hostPath:
path: /var/lib/etcd
type: ""
name: data-dir
- hostPath:
path: /usr/local/bin
name: usr-local-bin
- hostPath:
path: /var/log/etcd
name: log-dir
- hostPath:
path: /etc/kubernetes
name: config-dir
- hostPath:
path: /var/lib/etcd-auto-backup
name: etcd-auto-backup-dir
- emptyDir: {}
name: tmp-dir