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.

229 lines
7.7 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. {% if cilium_enable_prometheus %}
  31. prometheus.io/scrape: "true"
  32. prometheus.io/port: "9090"
  33. {% endif %}
  34. spec:
  35. {% if kube_version is version('v1.11.1', '>=') %}
  36. priorityClassName: system-node-critical
  37. {% endif %}
  38. serviceAccountName: cilium
  39. initContainers:
  40. - name: clean-cilium-state
  41. image: docker.io/library/busybox:1.28.4
  42. imagePullPolicy: IfNotPresent
  43. command: ['sh', '-c', 'if [ "${CLEAN_CILIUM_STATE}" = "true" ]; then rm -rf /var/run/cilium/state; rm -rf /sys/fs/bpf/tc/globals/cilium_*; fi']
  44. volumeMounts:
  45. - name: bpf-maps
  46. mountPath: /sys/fs/bpf
  47. - name: cilium-run
  48. mountPath: /var/run/cilium
  49. env:
  50. - name: "CLEAN_CILIUM_STATE"
  51. valueFrom:
  52. configMapKeyRef:
  53. name: cilium-config
  54. optional: true
  55. key: clean-cilium-state
  56. containers:
  57. - image: {{ cilium_image_repo }}:{{ cilium_image_tag }}
  58. imagePullPolicy: Always
  59. name: cilium-agent
  60. command: ["cilium-agent"]
  61. args:
  62. - "--debug=$(CILIUM_DEBUG)"
  63. - "--kvstore=etcd"
  64. - "--kvstore-opt=etcd.config=/var/lib/etcd-config/etcd.config"
  65. - "--disable-ipv4=$(DISABLE_IPV4)"
  66. {% if cilium_enable_prometheus %}
  67. ports:
  68. - name: prometheus
  69. containerPort: 9090
  70. {% endif %}
  71. lifecycle:
  72. postStart:
  73. exec:
  74. command:
  75. - "/cni-install.sh"
  76. preStop:
  77. exec:
  78. command:
  79. - "/cni-uninstall.sh"
  80. env:
  81. - name: "K8S_NODE_NAME"
  82. valueFrom:
  83. fieldRef:
  84. fieldPath: spec.nodeName
  85. - name: "CILIUM_DEBUG"
  86. valueFrom:
  87. configMapKeyRef:
  88. name: cilium-config
  89. key: debug
  90. - name: "DISABLE_IPV4"
  91. valueFrom:
  92. configMapKeyRef:
  93. name: cilium-config
  94. key: disable-ipv4
  95. {% if cilium_enable_prometheus %}
  96. # Note: this variable is a no-op if not defined, and is used in the
  97. # prometheus examples.
  98. - name: "CILIUM_PROMETHEUS_SERVE_ADDR"
  99. valueFrom:
  100. configMapKeyRef:
  101. name: cilium-metrics-config
  102. optional: true
  103. key: prometheus-serve-addr
  104. {% endif %}
  105. - name: "CILIUM_LEGACY_HOST_ALLOWS_WORLD"
  106. valueFrom:
  107. configMapKeyRef:
  108. name: cilium-config
  109. optional: true
  110. key: legacy-host-allows-world
  111. - name: "CILIUM_SIDECAR_ISTIO_PROXY_IMAGE"
  112. valueFrom:
  113. configMapKeyRef:
  114. name: cilium-config
  115. key: sidecar-istio-proxy-image
  116. optional: true
  117. - name: "CILIUM_TUNNEL"
  118. valueFrom:
  119. configMapKeyRef:
  120. key: tunnel
  121. name: cilium-config
  122. optional: true
  123. - name: "CILIUM_MONITOR_AGGREGATION_LEVEL"
  124. valueFrom:
  125. configMapKeyRef:
  126. key: monitor-aggregation-level
  127. name: cilium-config
  128. optional: true
  129. resources:
  130. limits:
  131. cpu: {{ cilium_cpu_limit }}
  132. memory: {{ cilium_memory_limit }}
  133. requests:
  134. cpu: {{ cilium_cpu_requests }}
  135. memory: {{ cilium_memory_requests }}
  136. livenessProbe:
  137. exec:
  138. command:
  139. - cilium
  140. - status
  141. # The initial delay for the liveness probe is intentionally large to
  142. # avoid an endless kill & restart cycle if in the event that the initial
  143. # bootstrapping takes longer than expected.
  144. initialDelaySeconds: 120
  145. failureThreshold: 10
  146. periodSeconds: 10
  147. readinessProbe:
  148. exec:
  149. command:
  150. - cilium
  151. - status
  152. initialDelaySeconds: 5
  153. periodSeconds: 5
  154. volumeMounts:
  155. - name: bpf-maps
  156. mountPath: /sys/fs/bpf
  157. - name: cilium-run
  158. mountPath: /var/run/cilium
  159. - name: cni-path
  160. mountPath: /host/opt/cni/bin
  161. - name: etc-cni-netd
  162. mountPath: /host/etc/cni/net.d
  163. {% if container_manager == 'crio' %}
  164. - name: crio-socket
  165. mountPath: /var/run/crio.sock
  166. readOnly: true
  167. {% else %}
  168. - name: docker-socket
  169. mountPath: /var/run/docker.sock
  170. readOnly: true
  171. {% endif %}
  172. - name: etcd-config-path
  173. mountPath: /var/lib/etcd-config
  174. readOnly: true
  175. - name: cilium-certs
  176. mountPath: {{ cilium_cert_dir }}
  177. readOnly: true
  178. securityContext:
  179. capabilities:
  180. add:
  181. - "NET_ADMIN"
  182. privileged: true
  183. hostNetwork: true
  184. volumes:
  185. # To keep state between restarts / upgrades
  186. - name: cilium-run
  187. hostPath:
  188. path: /var/run/cilium
  189. # To keep state between restarts / upgrades
  190. - name: bpf-maps
  191. hostPath:
  192. path: /sys/fs/bpf
  193. {% if container_manager == 'crio' %}
  194. # To read crio events from the node
  195. - name: crio-socket
  196. hostPath:
  197. path: /var/run/crio/crio.sock
  198. {% else %}
  199. # To read docker events from the node
  200. - name: docker-socket
  201. hostPath:
  202. path: /var/run/docker.sock
  203. {% endif %}
  204. # To install cilium cni plugin in the host
  205. - name: cni-path
  206. hostPath:
  207. path: /opt/cni/bin
  208. # To install cilium cni configuration in the host
  209. - name: etc-cni-netd
  210. hostPath:
  211. path: /etc/cni/net.d
  212. # To read the etcd config stored in config maps
  213. - name: etcd-config-path
  214. configMap:
  215. name: cilium-config
  216. items:
  217. - key: etcd-config
  218. path: etcd.config
  219. # To read the k8s etcd secrets in case the user might want to use TLS
  220. - name: cilium-certs
  221. hostPath:
  222. path: {{ cilium_cert_dir }}
  223. restartPolicy: Always
  224. tolerations:
  225. - operator: Exists
  226. # Mark pod as critical for rescheduling (Will have no effect starting with kubernetes 1.12)
  227. - key: CriticalAddonsOnly
  228. operator: "Exists"