You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

232 lines
7.8 KiB

  1. ---
  2. apiVersion: apps/v1
  3. kind: DaemonSet
  4. metadata:
  5. name: cilium
  6. namespace: kube-system
  7. spec:
  8. updateStrategy:
  9. type: "RollingUpdate"
  10. rollingUpdate:
  11. # Specifies the maximum number of Pods that can be unavailable during the update process.
  12. # The current default value is 1 or 100% for daemonsets; Adding an explicit value here
  13. # to avoid confusion, as the default value is specific to the type (daemonset/deployment).
  14. maxUnavailable: "100%"
  15. selector:
  16. matchLabels:
  17. k8s-app: cilium
  18. kubernetes.io/cluster-service: "true"
  19. template:
  20. metadata:
  21. labels:
  22. k8s-app: cilium
  23. kubernetes.io/cluster-service: "true"
  24. annotations:
  25. # This annotation plus the CriticalAddonsOnly toleration makes
  26. # cilium to be a critical pod in the cluster, which ensures cilium
  27. # gets priority scheduling.
  28. # https://kubernetes.io/docs/tasks/administer-cluster/guaranteed-scheduling-critical-addon-pods/
  29. scheduler.alpha.kubernetes.io/critical-pod: ''
  30. scheduler.alpha.kubernetes.io/tolerations: >-
  31. [{"key":"dedicated","operator":"Equal","value":"master","effect":"NoSchedule"}]
  32. {% if cilium_enable_prometheus %}
  33. prometheus.io/scrape: "true"
  34. prometheus.io/port: "9090"
  35. {% endif %}
  36. spec:
  37. serviceAccountName: cilium
  38. initContainers:
  39. - name: clean-cilium-state
  40. image: docker.io/library/busybox:1.28.4
  41. imagePullPolicy: IfNotPresent
  42. command: ['sh', '-c', 'if [ "${CLEAN_CILIUM_STATE}" = "true" ]; then rm -rf /var/run/cilium/state; rm -rf /sys/fs/bpf/tc/globals/cilium_*; fi']
  43. volumeMounts:
  44. - name: bpf-maps
  45. mountPath: /sys/fs/bpf
  46. - name: cilium-run
  47. mountPath: /var/run/cilium
  48. env:
  49. - name: "CLEAN_CILIUM_STATE"
  50. valueFrom:
  51. configMapKeyRef:
  52. name: cilium-config
  53. optional: true
  54. key: clean-cilium-state
  55. containers:
  56. - image: {{ cilium_image_repo }}:{{ cilium_image_tag }}
  57. imagePullPolicy: Always
  58. name: cilium-agent
  59. command: ["cilium-agent"]
  60. args:
  61. - "--debug=$(CILIUM_DEBUG)"
  62. - "--kvstore=etcd"
  63. - "--kvstore-opt=etcd.config=/var/lib/etcd-config/etcd.config"
  64. - "--disable-ipv4=$(DISABLE_IPV4)"
  65. {% if cilium_enable_prometheus %}
  66. ports:
  67. - name: prometheus
  68. containerPort: 9090
  69. {% endif %}
  70. lifecycle:
  71. postStart:
  72. exec:
  73. command:
  74. - "/cni-install.sh"
  75. preStop:
  76. exec:
  77. command:
  78. - "/cni-uninstall.sh"
  79. env:
  80. - name: "K8S_NODE_NAME"
  81. valueFrom:
  82. fieldRef:
  83. fieldPath: spec.nodeName
  84. - name: "CILIUM_DEBUG"
  85. valueFrom:
  86. configMapKeyRef:
  87. name: cilium-config
  88. key: debug
  89. - name: "DISABLE_IPV4"
  90. valueFrom:
  91. configMapKeyRef:
  92. name: cilium-config
  93. key: disable-ipv4
  94. {% if cilium_enable_prometheus %}
  95. # Note: this variable is a no-op if not defined, and is used in the
  96. # prometheus examples.
  97. - name: "CILIUM_PROMETHEUS_SERVE_ADDR"
  98. valueFrom:
  99. configMapKeyRef:
  100. name: cilium-metrics-config
  101. optional: true
  102. key: prometheus-serve-addr
  103. {% endif %}
  104. - name: "CILIUM_LEGACY_HOST_ALLOWS_WORLD"
  105. valueFrom:
  106. configMapKeyRef:
  107. name: cilium-config
  108. optional: true
  109. key: legacy-host-allows-world
  110. - name: "CILIUM_SIDECAR_ISTIO_PROXY_IMAGE"
  111. valueFrom:
  112. configMapKeyRef:
  113. name: cilium-config
  114. key: sidecar-istio-proxy-image
  115. optional: true
  116. - name: "CILIUM_TUNNEL"
  117. valueFrom:
  118. configMapKeyRef:
  119. key: tunnel
  120. name: cilium-config
  121. optional: true
  122. - name: "CILIUM_MONITOR_AGGREGATION_LEVEL"
  123. valueFrom:
  124. configMapKeyRef:
  125. key: monitor-aggregation-level
  126. name: cilium-config
  127. optional: true
  128. resources:
  129. limits:
  130. cpu: {{ cilium_cpu_limit }}
  131. memory: {{ cilium_memory_limit }}
  132. requests:
  133. cpu: {{ cilium_cpu_requests }}
  134. memory: {{ cilium_memory_requests }}
  135. livenessProbe:
  136. exec:
  137. command:
  138. - cilium
  139. - status
  140. # The initial delay for the liveness probe is intentionally large to
  141. # avoid an endless kill & restart cycle if in the event that the initial
  142. # bootstrapping takes longer than expected.
  143. initialDelaySeconds: 120
  144. failureThreshold: 10
  145. periodSeconds: 10
  146. readinessProbe:
  147. exec:
  148. command:
  149. - cilium
  150. - status
  151. initialDelaySeconds: 5
  152. periodSeconds: 5
  153. volumeMounts:
  154. - name: bpf-maps
  155. mountPath: /sys/fs/bpf
  156. - name: cilium-run
  157. mountPath: /var/run/cilium
  158. - name: cni-path
  159. mountPath: /host/opt/cni/bin
  160. - name: etc-cni-netd
  161. mountPath: /host/etc/cni/net.d
  162. {% if container_manager == 'crio' %}
  163. - name: crio-socket
  164. mountPath: /var/run/crio.sock
  165. readOnly: true
  166. {% else %}
  167. - name: docker-socket
  168. mountPath: /var/run/docker.sock
  169. readOnly: true
  170. {% endif %}
  171. - name: etcd-config-path
  172. mountPath: /var/lib/etcd-config
  173. readOnly: true
  174. - name: cilium-certs
  175. mountPath: {{ cilium_cert_dir }}
  176. readOnly: true
  177. securityContext:
  178. capabilities:
  179. add:
  180. - "NET_ADMIN"
  181. privileged: true
  182. hostNetwork: true
  183. volumes:
  184. # To keep state between restarts / upgrades
  185. - name: cilium-run
  186. hostPath:
  187. path: /var/run/cilium
  188. # To keep state between restarts / upgrades
  189. - name: bpf-maps
  190. hostPath:
  191. path: /sys/fs/bpf
  192. {% if container_manager == 'crio' %}
  193. # To read crio events from the node
  194. - name: crio-socket
  195. hostPath:
  196. path: /var/run/crio/crio.sock
  197. {% else %}
  198. # To read docker events from the node
  199. - name: docker-socket
  200. hostPath:
  201. path: /var/run/docker.sock
  202. {% endif %}
  203. # To install cilium cni plugin in the host
  204. - name: cni-path
  205. hostPath:
  206. path: /opt/cni/bin
  207. # To install cilium cni configuration in the host
  208. - name: etc-cni-netd
  209. hostPath:
  210. path: /etc/cni/net.d
  211. # To read the etcd config stored in config maps
  212. - name: etcd-config-path
  213. configMap:
  214. name: cilium-config
  215. items:
  216. - key: etcd-config
  217. path: etcd.config
  218. # To read the k8s etcd secrets in case the user might want to use TLS
  219. - name: cilium-certs
  220. hostPath:
  221. path: {{ cilium_cert_dir }}
  222. restartPolicy: Always
  223. tolerations:
  224. - effect: NoSchedule
  225. key: node-role.kubernetes.io/master
  226. - effect: NoSchedule
  227. key: node.cloudprovider.kubernetes.io/uninitialized
  228. value: "true"
  229. # Mark cilium's pod as critical for rescheduling
  230. - key: CriticalAddonsOnly
  231. operator: "Exists"