/
daemonset.yaml
422 lines (422 loc) · 14 KB
/
daemonset.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
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
k8s-app: cilium
{{- if .Values.keepDeprecatedLabels }}
kubernetes.io/cluster-service: "true"
{{- end }}
name: cilium
namespace: {{ .Release.Namespace }}
spec:
selector:
matchLabels:
k8s-app: cilium
{{- if .Values.keepDeprecatedLabels }}
kubernetes.io/cluster-service: "true"
{{- end }}
template:
metadata:
annotations:
{{- if and .Values.global.prometheus.enabled (not .Values.global.prometheus.serviceMonitor.enabled) }}
prometheus.io/port: "{{ .Values.global.prometheus.port }}"
prometheus.io/scrape: "true"
{{- end }}
# This annotation plus the CriticalAddonsOnly toleration makes
# cilium to be a critical pod in the cluster, which ensures cilium
# gets priority scheduling.
# https://kubernetes.io/docs/tasks/administer-cluster/guaranteed-scheduling-critical-addon-pods/
scheduler.alpha.kubernetes.io/critical-pod: ""
labels:
k8s-app: cilium
{{- if .Values.keepDeprecatedLabels }}
kubernetes.io/cluster-service: "true"
{{- end }}
spec:
{{- if .Values.global.affinity }}
affinity:
{{ toYaml .Values.global.affinity | indent 8 }}
{{- end }}
containers:
{{- if .Values.sleepAfterInit }}
- command: [ "/bin/bash", "-c", "--" ]
args: [ "while true; do sleep 30; done;" ]
livenessProbe:
exec:
command:
- "true"
readinessProbe:
exec:
command:
- "true"
{{- else }}
- args:
- --config-dir=/tmp/cilium/config-map
command:
- cilium-agent
livenessProbe:
httpGet:
host: '127.0.0.1'
path: /healthz
port: {{ .Values.global.agent.healthPort }}
scheme: HTTP
failureThreshold: 10
# The initial delay for the liveness probe is intentionally large to
# avoid an endless kill & restart cycle if in the event that the initial
# bootstrapping takes longer than expected.
initialDelaySeconds: 120
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 5
readinessProbe:
httpGet:
host: '127.0.0.1'
path: /healthz
port: {{ .Values.global.agent.healthPort }}
scheme: HTTP
failureThreshold: 3
initialDelaySeconds: 5
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 5
{{- end }}
env:
- name: K8S_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
{{- if .Values.global.ci.kubeCacheMutationDetector }}
- name: KUBE_CACHE_MUTATION_DETECTOR
value: "true"
{{- end }}
- name: CILIUM_K8S_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: CILIUM_FLANNEL_MASTER_DEVICE
valueFrom:
configMapKeyRef:
key: flannel-master-device
name: cilium-config
optional: true
- name: CILIUM_FLANNEL_UNINSTALL_ON_EXIT
valueFrom:
configMapKeyRef:
key: flannel-uninstall-on-exit
name: cilium-config
optional: true
- name: CILIUM_CLUSTERMESH_CONFIG
value: /var/lib/cilium/clustermesh/
- name: CILIUM_CNI_CHAINING_MODE
valueFrom:
configMapKeyRef:
key: cni-chaining-mode
name: cilium-config
optional: true
- name: CILIUM_CUSTOM_CNI_CONF
valueFrom:
configMapKeyRef:
key: custom-cni-conf
name: cilium-config
optional: true
{{- if .Values.global.k8sServiceHost }}
- name: KUBERNETES_SERVICE_HOST
value: {{ .Values.global.k8sServiceHost | quote }}
{{- end }}
{{- if .Values.global.k8sServicePort }}
- name: KUBERNETES_SERVICE_PORT
value: {{ .Values.global.k8sServicePort | quote }}
{{- end }}
{{- if contains "/" .Values.image }}
image: "{{ .Values.image }}"
{{- else }}
image: "{{ .Values.global.registry }}/{{ .Values.image }}:{{ .Values.global.tag }}"
{{- end }}
imagePullPolicy: {{ .Values.global.pullPolicy }}
{{- if .Values.global.cni.install }}
lifecycle:
postStart:
exec:
command:
- "/cni-install.sh"
-{{- if .Values.global.debug.enabled }} "--enable-debug=true"{{- else }} "--enable-debug=false"{{- end }}
preStop:
exec:
command:
- /cni-uninstall.sh
{{- end }}
{{- if .Values.resources }}
resources:
{{- toYaml .Values.resources | trim | nindent 10 }}
{{- end }}
name: cilium-agent
{{- if or .Values.global.prometheus.enabled .Values.global.hubble.metricsServer }}
ports:
{{- if .Values.global.prometheus.enabled }}
- containerPort: {{ .Values.global.prometheus.port }}
hostPort: {{ .Values.global.prometheus.port }}
name: prometheus
protocol: TCP
{{- end }}
{{- if .Values.global.hubble.metricsServer }}
- containerPort: {{ regexReplaceAll ":([0-9]+)$" .Values.global.hubble.metricsServer "${1}" }}
hostPort: {{ regexReplaceAll ":([0-9]+)$" .Values.global.hubble.metricsServer "${1}" }}
name: hubble-metrics
protocol: TCP
{{- end }}
{{- end }}
securityContext:
capabilities:
add:
- NET_ADMIN
- SYS_MODULE
privileged: true
volumeMounts:
{{- /* CRI-O already mounts the BPF filesystem */ -}}
{{- if not (eq .Values.global.containerRuntime.integration "crio") }}
- mountPath: /sys/fs/bpf
name: bpf-maps
{{- end }}
- mountPath: /var/run/cilium
name: cilium-run
- mountPath: /host/opt/cni/bin
name: cni-path
- mountPath: {{ .Values.global.cni.hostConfDirMountPath }}
name: etc-cni-netd
{{- if .Values.global.etcd.enabled }}
- mountPath: /var/lib/etcd-config
name: etcd-config-path
readOnly: true
{{- if or .Values.global.etcd.ssl .Values.global.etcd.managed }}
- mountPath: /var/lib/etcd-secrets
name: etcd-secrets
readOnly: true
{{- end }}
{{- end }}
- mountPath: /var/lib/cilium/clustermesh
name: clustermesh-secrets
readOnly: true
- mountPath: /tmp/cilium/config-map
name: cilium-config-path
readOnly: true
{{- if and .Values.global.ipMasqAgent .Values.global.ipMasqAgent.enabled }}
- mountPath: /etc/config
name: ip-masq-agent
readOnly: true
{{- end }}
{{- if .Values.global.cni.configMap }}
- mountPath: {{ .Values.global.cni.confFileMountPath }}
name: cni-configuration
readOnly: true
{{- end }}
# Needed to be able to load kernel modules
- mountPath: /lib/modules
name: lib-modules
readOnly: true
- mountPath: /run/xtables.lock
name: xtables-lock
{{- if .Values.global.encryption.enabled }}
- mountPath: {{ .Values.global.encryption.mountPath }}
name: cilium-ipsec-secrets
{{- end }}
{{- if .Values.global.kubeConfigPath }}
- mountPath: {{ .Values.global.kubeConfigPath }}
name: kube-config
readOnly: true
{{- end}}
{{- if .Values.monitor.enabled }}
- name: cilium-monitor
command: ["cilium"]
args:
- monitor
{{- range $type := .Values.monitor.eventTypes }}
- --type={{ $type }}
{{- end }}
{{- if contains "/" .Values.image }}
image: "{{ .Values.image }}"
{{- else }}
image: "{{ .Values.global.registry }}/{{ .Values.image }}:{{ .Values.global.tag }}"
{{- end }}
imagePullPolicy: {{ .Values.global.pullPolicy }}
volumeMounts:
- mountPath: /var/run/cilium
name: cilium-run
{{- if .Values.monitor.resources }}
resources:
{{- toYaml .Values.monitor.resources | trim | nindent 10 }}
{{- end }}
{{- end }}
{{- if .Values.global.etcd.managed }}
# In managed etcd mode, Cilium must be able to resolve the DNS name of
# the etcd service
dnsPolicy: ClusterFirstWithHostNet
{{- end }}
hostNetwork: true
initContainers:
{{- if and .Values.global.nodeinit.enabled (not (eq .Values.global.nodeinit.bootstrapFile "")) }}
- name: wait-for-node-init
command: ['sh', '-c', 'until stat {{ .Values.global.nodeinit.bootstrapFile }} > /dev/null 2>&1; do echo "Waiting on node-init to run..."; sleep 1; done']
{{- if contains "/" .Values.image }}
image: "{{ .Values.image }}"
{{- else }}
image: "{{ .Values.global.registry }}/{{ .Values.image }}:{{ .Values.global.tag }}"
{{- end }}
imagePullPolicy: {{ .Values.global.pullPolicy }}
volumeMounts:
- mountPath: {{ .Values.global.nodeinit.bootstrapFile }}
name: cilium-bootstrap-file
{{- end }}
- command:
- /init-container.sh
env:
- name: CILIUM_ALL_STATE
valueFrom:
configMapKeyRef:
key: clean-cilium-state
name: cilium-config
optional: true
- name: CILIUM_BPF_STATE
valueFrom:
configMapKeyRef:
key: clean-cilium-bpf-state
name: cilium-config
optional: true
- name: CILIUM_WAIT_BPF_MOUNT
valueFrom:
configMapKeyRef:
key: wait-bpf-mount
name: cilium-config
optional: true
{{- if contains "/" .Values.image }}
image: "{{ .Values.image }}"
{{- else }}
image: "{{ .Values.global.registry }}/{{ .Values.image }}:{{ .Values.global.tag }}"
{{- end }}
imagePullPolicy: {{ .Values.global.pullPolicy }}
name: clean-cilium-state
securityContext:
capabilities:
add:
- NET_ADMIN
privileged: true
volumeMounts:
{{- /* CRI-O already mounts the BPF filesystem */ -}}
{{- if not (eq .Values.global.containerRuntime.integration "crio") }}
- mountPath: /sys/fs/bpf
name: bpf-maps
{{- /* Required for wait-bpf-mount to work */}}
mountPropagation: HostToContainer
{{- end }}
- mountPath: /var/run/cilium
name: cilium-run
{{- if .Values.initResources }}
resources:
{{- toYaml .Values.initResources | trim | nindent 10 }}
{{- end }}
restartPolicy: Always
{{- if or (and (eq .Release.Namespace "kube-system") (gt .Capabilities.KubeVersion.Minor "10")) (gt .Capabilities.KubeVersion.Minor "16") (gt .Capabilities.KubeVersion.Major "1")}}
priorityClassName: system-node-critical
{{- end }}
serviceAccount: cilium
serviceAccountName: cilium
terminationGracePeriodSeconds: 1
tolerations:
- operator: Exists
volumes:
# To keep state between restarts / upgrades
- hostPath:
path: {{ .Values.global.daemon.runPath }}
type: DirectoryOrCreate
name: cilium-run
{{- /* CRI-O already mounts the BPF filesystem */ -}}
{{- if not (eq .Values.global.containerRuntime.integration "crio") }}
# To keep state between restarts / upgrades for bpf maps
- hostPath:
path: /sys/fs/bpf
type: DirectoryOrCreate
name: bpf-maps
{{- end }}
# To install cilium cni plugin in the host
- hostPath:
path: {{ .Values.global.cni.binPath }}
type: DirectoryOrCreate
name: cni-path
# To install cilium cni configuration in the host
- hostPath:
path: {{ .Values.global.cni.confPath }}
type: DirectoryOrCreate
name: etc-cni-netd
# To be able to load kernel modules
- hostPath:
path: /lib/modules
name: lib-modules
# To access iptables concurrently with other processes (e.g. kube-proxy)
- hostPath:
path: /run/xtables.lock
type: FileOrCreate
name: xtables-lock
{{- if .Values.global.kubeConfigPath }}
- hostPath:
path: {{ .Values.global.kubeConfigPath }}
type: FileOrCreate
name: kube-config
{{- end }}
{{- if and .Values.global.nodeinit.enabled (not (eq .Values.global.nodeinit.bootstrapFile "")) }}
- hostPath:
path: {{ .Values.global.nodeinit.bootstrapFile }}
type: FileOrCreate
name: cilium-bootstrap-file
{{- end }}
{{- if .Values.global.etcd.enabled }}
# To read the etcd config stored in config maps
- configMap:
defaultMode: 420
items:
- key: etcd-config
path: etcd.config
name: cilium-config
name: etcd-config-path
# To read the k8s etcd secrets in case the user might want to use TLS
{{- if or .Values.global.etcd.ssl .Values.global.etcd.managed }}
- name: etcd-secrets
secret:
defaultMode: 420
optional: true
secretName: cilium-etcd-secrets
{{- end }}
{{- end }}
# To read the clustermesh configuration
- name: clustermesh-secrets
secret:
defaultMode: 420
optional: true
secretName: cilium-clustermesh
# To read the configuration from the config map
- configMap:
name: cilium-config
name: cilium-config-path
{{- if and .Values.global.ipMasqAgent .Values.global.ipMasqAgent.enabled }}
- configMap:
name: ip-masq-agent
optional: true
items:
- key: config
path: ip-masq-agent
name: ip-masq-agent
{{- end }}
{{- if .Values.global.encryption.enabled }}
- name: cilium-ipsec-secrets
secret:
secretName: {{ .Values.global.encryption.secretName }}
{{- end }}
{{- if .Values.global.cni.configMap }}
- name: cni-configuration
configMap:
name: {{ .Values.global.cni.configMap }}
{{- end }}
updateStrategy:
rollingUpdate:
maxUnavailable: {{ .Values.maxUnavailable }}
type: RollingUpdate