2018-07-27 04:17:27 +08:00
|
|
|
apiVersion: apps/v1
|
2018-02-17 11:37:47 +08:00
|
|
|
kind: DaemonSet
|
|
|
|
metadata:
|
2019-08-06 16:37:55 +08:00
|
|
|
labels:
|
|
|
|
k8s-app: cilium
|
2018-02-17 11:37:47 +08:00
|
|
|
name: cilium
|
2018-03-30 19:29:13 +08:00
|
|
|
namespace: kube-system
|
2018-02-17 11:37:47 +08:00
|
|
|
spec:
|
2018-07-27 04:17:27 +08:00
|
|
|
selector:
|
|
|
|
matchLabels:
|
|
|
|
k8s-app: cilium
|
2018-02-17 11:37:47 +08:00
|
|
|
template:
|
|
|
|
metadata:
|
2019-08-06 16:37:55 +08:00
|
|
|
annotations:
|
2018-02-17 11:37:47 +08:00
|
|
|
{% if cilium_enable_prometheus %}
|
|
|
|
prometheus.io/port: "9090"
|
2019-08-06 16:37:55 +08:00
|
|
|
prometheus.io/scrape: "true"
|
2018-02-17 11:37:47 +08:00
|
|
|
{% endif %}
|
2019-08-06 16:37:55 +08:00
|
|
|
# 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: ""
|
|
|
|
scheduler.alpha.kubernetes.io/tolerations: '[{"key":"dedicated","operator":"Equal","value":"master","effect":"NoSchedule"}]'
|
|
|
|
labels:
|
|
|
|
k8s-app: cilium
|
2018-02-17 11:37:47 +08:00
|
|
|
spec:
|
|
|
|
containers:
|
2019-08-06 16:37:55 +08:00
|
|
|
- args:
|
|
|
|
- --kvstore=etcd
|
|
|
|
- --kvstore-opt=etcd.config=/var/lib/etcd-config/etcd.config
|
|
|
|
- --config-dir=/tmp/cilium/config-map
|
|
|
|
command:
|
|
|
|
- cilium-agent
|
|
|
|
env:
|
|
|
|
- name: K8S_NODE_NAME
|
|
|
|
valueFrom:
|
|
|
|
fieldRef:
|
|
|
|
apiVersion: v1
|
|
|
|
fieldPath: spec.nodeName
|
|
|
|
- name: CILIUM_K8S_NAMESPACE
|
|
|
|
valueFrom:
|
|
|
|
fieldRef:
|
|
|
|
apiVersion: v1
|
|
|
|
fieldPath: metadata.namespace
|
|
|
|
- name: CILIUM_CLUSTERMESH_CONFIG
|
|
|
|
value: /var/lib/cilium/clustermesh/
|
|
|
|
image: "{{cilium_image_repo}}:{{cilium_image_tag}}"
|
|
|
|
imagePullPolicy: IfNotPresent
|
|
|
|
resources:
|
|
|
|
limits:
|
|
|
|
cpu: {{ cilium_cpu_limit }}
|
|
|
|
memory: {{ cilium_memory_limit }}
|
|
|
|
requests:
|
|
|
|
cpu: {{ cilium_cpu_requests }}
|
|
|
|
memory: {{ cilium_memory_requests }}
|
|
|
|
lifecycle:
|
|
|
|
postStart:
|
2018-02-17 11:37:47 +08:00
|
|
|
exec:
|
|
|
|
command:
|
2019-08-06 16:37:55 +08:00
|
|
|
- /cni-install.sh
|
|
|
|
preStop:
|
2018-02-17 11:37:47 +08:00
|
|
|
exec:
|
|
|
|
command:
|
2019-08-06 16:37:55 +08:00
|
|
|
- /cni-uninstall.sh
|
|
|
|
livenessProbe:
|
|
|
|
exec:
|
|
|
|
command:
|
|
|
|
- cilium
|
|
|
|
- status
|
|
|
|
- --brief
|
|
|
|
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
|
|
|
|
name: cilium-agent
|
|
|
|
{% if cilium_enable_prometheus %}
|
|
|
|
ports:
|
|
|
|
- containerPort: 9090
|
|
|
|
hostPort: 9090
|
|
|
|
name: prometheus
|
|
|
|
protocol: TCP
|
|
|
|
{% endif %}
|
|
|
|
readinessProbe:
|
|
|
|
exec:
|
|
|
|
command:
|
|
|
|
- cilium
|
|
|
|
- status
|
|
|
|
- --brief
|
|
|
|
failureThreshold: 3
|
|
|
|
initialDelaySeconds: 5
|
|
|
|
periodSeconds: 30
|
|
|
|
successThreshold: 1
|
|
|
|
timeoutSeconds: 5
|
|
|
|
securityContext:
|
|
|
|
capabilities:
|
|
|
|
add:
|
|
|
|
- NET_ADMIN
|
|
|
|
- SYS_MODULE
|
|
|
|
privileged: true
|
|
|
|
volumeMounts:
|
|
|
|
- mountPath: /sys/fs/bpf
|
|
|
|
name: bpf-maps
|
|
|
|
- mountPath: /var/run/cilium
|
|
|
|
name: cilium-run
|
|
|
|
- mountPath: /host/opt/cni/bin
|
|
|
|
name: cni-path
|
|
|
|
- mountPath: /host/etc/cni/net.d
|
|
|
|
name: etc-cni-netd
|
2019-06-30 05:09:20 +08:00
|
|
|
{% if container_manager == 'docker' %}
|
2019-08-06 16:37:55 +08:00
|
|
|
- mountPath: /var/run/docker.sock
|
|
|
|
name: docker-socket
|
|
|
|
readOnly: true
|
2019-06-30 05:09:20 +08:00
|
|
|
{% else %}
|
2019-11-11 19:25:41 +08:00
|
|
|
- name: "{{ container_manager }}-socket"
|
|
|
|
mountPath: {{ cri_socket }}
|
|
|
|
readOnly: true
|
2018-09-12 23:35:28 +08:00
|
|
|
{% endif %}
|
2019-08-06 16:37:55 +08:00
|
|
|
- mountPath: /var/lib/etcd-config
|
|
|
|
name: etcd-config-path
|
|
|
|
readOnly: true
|
|
|
|
- mountPath: "{{cilium_cert_dir}}"
|
|
|
|
name: etcd-secrets
|
|
|
|
readOnly: true
|
|
|
|
- mountPath: /var/lib/cilium/clustermesh
|
|
|
|
name: clustermesh-secrets
|
|
|
|
readOnly: true
|
|
|
|
- mountPath: /tmp/cilium/config-map
|
|
|
|
name: cilium-config-path
|
|
|
|
readOnly: true
|
|
|
|
# Needed to be able to load kernel modules
|
|
|
|
- mountPath: /lib/modules
|
|
|
|
name: lib-modules
|
|
|
|
readOnly: true
|
2019-06-05 18:17:56 +08:00
|
|
|
dnsPolicy: ClusterFirstWithHostNet
|
2019-08-06 16:37:55 +08:00
|
|
|
hostNetwork: true
|
|
|
|
hostPID: false
|
|
|
|
initContainers:
|
|
|
|
- command:
|
|
|
|
- /init-container.sh
|
|
|
|
env:
|
|
|
|
- name: CLEAN_CILIUM_STATE
|
|
|
|
valueFrom:
|
|
|
|
configMapKeyRef:
|
|
|
|
key: clean-cilium-state
|
|
|
|
name: cilium-config
|
|
|
|
optional: true
|
|
|
|
- name: CLEAN_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
|
|
|
|
image: "{{cilium_init_image_repo}}:{{cilium_init_image_tag}}"
|
|
|
|
imagePullPolicy: IfNotPresent
|
|
|
|
name: clean-cilium-state
|
|
|
|
securityContext:
|
|
|
|
capabilities:
|
|
|
|
add:
|
|
|
|
- NET_ADMIN
|
|
|
|
privileged: true
|
|
|
|
volumeMounts:
|
|
|
|
- mountPath: /sys/fs/bpf
|
|
|
|
name: bpf-maps
|
|
|
|
- mountPath: /var/run/cilium
|
|
|
|
name: cilium-run
|
|
|
|
priorityClassName: system-node-critical
|
|
|
|
restartPolicy: Always
|
|
|
|
serviceAccount: cilium
|
|
|
|
serviceAccountName: cilium
|
|
|
|
terminationGracePeriodSeconds: 1
|
|
|
|
tolerations:
|
|
|
|
- operator: Exists
|
2018-02-17 11:37:47 +08:00
|
|
|
volumes:
|
2018-07-27 04:17:27 +08:00
|
|
|
# To keep state between restarts / upgrades
|
2019-08-06 16:37:55 +08:00
|
|
|
- hostPath:
|
|
|
|
path: /var/run/cilium
|
|
|
|
type: DirectoryOrCreate
|
|
|
|
name: cilium-run
|
|
|
|
# To keep state between restarts / upgrades for bpf maps
|
|
|
|
- hostPath:
|
|
|
|
path: /sys/fs/bpf
|
|
|
|
type: DirectoryOrCreate
|
|
|
|
name: bpf-maps
|
2019-06-30 05:09:20 +08:00
|
|
|
{% if container_manager == 'docker' %}
|
2018-07-27 04:17:27 +08:00
|
|
|
# To read docker events from the node
|
2019-08-06 16:37:55 +08:00
|
|
|
- hostPath:
|
|
|
|
path: /var/run/docker.sock
|
|
|
|
type: Socket
|
|
|
|
name: docker-socket
|
2019-06-30 05:09:20 +08:00
|
|
|
{% else %}
|
|
|
|
# To read crio events from the node
|
2019-08-06 16:37:55 +08:00
|
|
|
- hostPath:
|
|
|
|
path: {{ cri_socket }}
|
|
|
|
type: Socket
|
|
|
|
name: {{ container_manager }}-socket
|
2018-09-12 23:35:28 +08:00
|
|
|
{% endif %}
|
2018-07-27 04:17:27 +08:00
|
|
|
# To install cilium cni plugin in the host
|
2019-08-06 16:37:55 +08:00
|
|
|
- hostPath:
|
|
|
|
path: /opt/cni/bin
|
|
|
|
type: DirectoryOrCreate
|
|
|
|
name: cni-path
|
2018-07-27 04:17:27 +08:00
|
|
|
# To install cilium cni configuration in the host
|
2019-08-06 16:37:55 +08:00
|
|
|
- hostPath:
|
|
|
|
path: /etc/cni/net.d
|
|
|
|
type: DirectoryOrCreate
|
|
|
|
name: etc-cni-netd
|
|
|
|
# To be able to load kernel modules
|
|
|
|
- hostPath:
|
|
|
|
path: /lib/modules
|
|
|
|
name: lib-modules
|
2018-07-27 04:17:27 +08:00
|
|
|
# To read the etcd config stored in config maps
|
2019-08-06 16:37:55 +08:00
|
|
|
- configMap:
|
|
|
|
defaultMode: 420
|
|
|
|
items:
|
|
|
|
- key: etcd-config
|
|
|
|
path: etcd.config
|
|
|
|
name: cilium-config
|
|
|
|
name: etcd-config-path
|
2018-07-27 04:17:27 +08:00
|
|
|
# To read the k8s etcd secrets in case the user might want to use TLS
|
2019-08-06 16:37:55 +08:00
|
|
|
- name: etcd-secrets
|
|
|
|
hostPath:
|
|
|
|
path: "{{cilium_cert_dir}}"
|
|
|
|
# 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
|
|
|
|
updateStrategy:
|
|
|
|
rollingUpdate:
|
|
|
|
# Specifies the maximum number of Pods that can be unavailable during the update process.
|
|
|
|
maxUnavailable: 2
|
|
|
|
type: RollingUpdate
|