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.

369 lines
13 KiB

  1. ---
  2. # This manifest installs the calico/node container, as well
  3. # as the Calico CNI plugins and network config on
  4. # each master and worker node in a Kubernetes cluster.
  5. kind: DaemonSet
  6. apiVersion: apps/v1
  7. metadata:
  8. name: calico-node
  9. namespace: kube-system
  10. labels:
  11. k8s-app: calico-node
  12. spec:
  13. selector:
  14. matchLabels:
  15. k8s-app: calico-node
  16. template:
  17. metadata:
  18. labels:
  19. k8s-app: calico-node
  20. annotations:
  21. {% if calico_datastore == "etcd" %}
  22. kubespray.etcd-cert/serial: "{{ etcd_client_cert_serial }}"
  23. {% endif %}
  24. {% if calico_felix_prometheusmetricsenabled %}
  25. prometheus.io/scrape: 'true'
  26. prometheus.io/port: "{{ calico_felix_prometheusmetricsport }}"
  27. {% endif %}
  28. spec:
  29. priorityClassName: system-node-critical
  30. hostNetwork: true
  31. serviceAccountName: calico-node
  32. tolerations:
  33. - operator: Exists
  34. # Minimize downtime during a rolling upgrade or deletion; tell Kubernetes to do a "force
  35. # deletion": https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods.
  36. terminationGracePeriodSeconds: 0
  37. initContainers:
  38. {% if calico_datastore == "kdd" %}
  39. # This container performs upgrade from host-local IPAM to calico-ipam.
  40. # It can be deleted if this is a fresh installation, or if you have already
  41. # upgraded to use calico-ipam.
  42. - name: upgrade-ipam
  43. image: {{ calico_cni_image_repo }}:{{ calico_cni_image_tag }}
  44. command: ["/opt/cni/bin/calico-ipam", "-upgrade"]
  45. env:
  46. - name: KUBERNETES_NODE_NAME
  47. valueFrom:
  48. fieldRef:
  49. fieldPath: spec.nodeName
  50. - name: CALICO_NETWORKING_BACKEND
  51. valueFrom:
  52. configMapKeyRef:
  53. name: calico-config
  54. key: calico_backend
  55. volumeMounts:
  56. - mountPath: /var/lib/cni/networks
  57. name: host-local-net-dir
  58. - mountPath: /host/opt/cni/bin
  59. name: cni-bin-dir
  60. securityContext:
  61. privileged: true
  62. {% endif %}
  63. # This container installs the Calico CNI binaries
  64. # and CNI network config file on each node.
  65. - name: install-cni
  66. image: {{ calico_cni_image_repo }}:{{ calico_cni_image_tag }}
  67. command: ["{{ (calico_version is version('v3.16.0', '<'))|ternary('/install-cni.sh','/opt/cni/bin/install') }}"]
  68. env:
  69. # Name of the CNI config file to create.
  70. - name: CNI_CONF_NAME
  71. value: "10-calico.conflist"
  72. # Install CNI binaries
  73. - name: UPDATE_CNI_BINARIES
  74. value: "true"
  75. # The CNI network config to install on each node.
  76. - name: CNI_NETWORK_CONFIG_FILE
  77. value: "/host/etc/cni/net.d/calico.conflist.template"
  78. # Prevents the container from sleeping forever.
  79. - name: SLEEP
  80. value: "false"
  81. {% if calico_datastore == "kdd" %}
  82. # Set the hostname based on the k8s node name.
  83. - name: KUBERNETES_NODE_NAME
  84. valueFrom:
  85. fieldRef:
  86. fieldPath: spec.nodeName
  87. {% endif %}
  88. volumeMounts:
  89. - mountPath: /host/etc/cni/net.d
  90. name: cni-net-dir
  91. - mountPath: /host/opt/cni/bin
  92. name: cni-bin-dir
  93. securityContext:
  94. privileged: true
  95. containers:
  96. # Runs calico/node container on each Kubernetes node. This
  97. # container programs network policy and routes on each
  98. # host.
  99. - name: calico-node
  100. image: {{ calico_node_image_repo }}:{{ calico_node_image_tag }}
  101. env:
  102. # The location of the Calico etcd cluster.
  103. {% if calico_datastore == "etcd" %}
  104. - name: ETCD_ENDPOINTS
  105. valueFrom:
  106. configMapKeyRef:
  107. name: calico-config
  108. key: etcd_endpoints
  109. # Location of the CA certificate for etcd.
  110. - name: ETCD_CA_CERT_FILE
  111. valueFrom:
  112. configMapKeyRef:
  113. name: calico-config
  114. key: etcd_ca
  115. # Location of the client key for etcd.
  116. - name: ETCD_KEY_FILE
  117. valueFrom:
  118. configMapKeyRef:
  119. name: calico-config
  120. key: etcd_key
  121. # Location of the client certificate for etcd.
  122. - name: ETCD_CERT_FILE
  123. valueFrom:
  124. configMapKeyRef:
  125. name: calico-config
  126. key: etcd_cert
  127. {% elif calico_datastore == "kdd" %}
  128. # Use Kubernetes API as the backing datastore.
  129. - name: DATASTORE_TYPE
  130. value: "kubernetes"
  131. {% if typha_enabled %}
  132. # Typha support: controlled by the ConfigMap.
  133. - name: FELIX_TYPHAK8SSERVICENAME
  134. valueFrom:
  135. configMapKeyRef:
  136. name: calico-config
  137. key: typha_service_name
  138. {% if typha_secure %}
  139. - name: FELIX_TYPHACN
  140. value: typha-server
  141. - name: FELIX_TYPHACAFILE
  142. value: /etc/typha-ca/ca.crt
  143. - name: FELIX_TYPHACERTFILE
  144. value: /etc/typha-client/typha-client.crt
  145. - name: FELIX_TYPHAKEYFILE
  146. value: /etc/typha-client/typha-client.key
  147. {% endif %}
  148. {% endif %}
  149. # Wait for the datastore.
  150. - name: WAIT_FOR_DATASTORE
  151. value: "true"
  152. {% endif %}
  153. {% if calico_network_backend is defined and calico_network_backend == 'vxlan' %}
  154. - name: FELIX_VXLANVNI
  155. value: "{{ calico_vxlan_vni }}"
  156. - name: FELIX_VXLANPORT
  157. value: "{{ calico_vxlan_port }}"
  158. {% endif %}
  159. # Choose the backend to use.
  160. - name: CALICO_NETWORKING_BACKEND
  161. valueFrom:
  162. configMapKeyRef:
  163. name: calico-config
  164. key: calico_backend
  165. # Cluster type to identify the deployment type
  166. - name: CLUSTER_TYPE
  167. valueFrom:
  168. configMapKeyRef:
  169. name: calico-config
  170. key: cluster_type
  171. # Set noderef for node controller.
  172. - name: CALICO_K8S_NODE_REF
  173. valueFrom:
  174. fieldRef:
  175. fieldPath: spec.nodeName
  176. # Disable file logging so `kubectl logs` works.
  177. - name: CALICO_DISABLE_FILE_LOGGING
  178. value: "true"
  179. # Set Felix endpoint to host default action to ACCEPT.
  180. - name: FELIX_DEFAULTENDPOINTTOHOSTACTION
  181. value: "{{ calico_endpoint_to_host_action|default('RETURN') }}"
  182. - name: FELIX_HEALTHHOST
  183. value: "{{ calico_healthhost }}"
  184. {% if kube_proxy_mode == 'ipvs' and kube_apiserver_node_port_range is defined %}
  185. - name: FELIX_KUBENODEPORTRANGES
  186. value: "{{ kube_apiserver_node_port_range.split('-')[0] }}:{{ kube_apiserver_node_port_range.split('-')[1] }}"
  187. {% endif %}
  188. - name: FELIX_IPTABLESBACKEND
  189. value: "{{ calico_iptables_backend }}"
  190. - name: FELIX_IPTABLESLOCKTIMEOUTSECS
  191. value: "{{ calico_iptables_lock_timeout_secs }}"
  192. # should be set in etcd before deployment
  193. # # Configure the IP Pool from which Pod IPs will be chosen.
  194. # - name: CALICO_IPV4POOL_CIDR
  195. # value: "{{ calico_pool_cidr | default(kube_pods_subnet) }}"
  196. {% if calico_veth_mtu is defined %}
  197. # Set MTU for the Wireguard tunnel device.
  198. - name: FELIX_WIREGUARDMTU
  199. value: "{{ calico_veth_mtu }}"
  200. {% endif %}
  201. - name: CALICO_IPV4POOL_IPIP
  202. value: "{{ calico_ipv4pool_ipip }}"
  203. # Disable IPv6 on Kubernetes.
  204. - name: FELIX_IPV6SUPPORT
  205. value: "false"
  206. # Set Felix logging to "info"
  207. - name: FELIX_LOGSEVERITYSCREEN
  208. value: "{{ calico_loglevel }}"
  209. # Enable or disable usage report
  210. - name: FELIX_USAGEREPORTINGENABLED
  211. value: "{{ calico_usage_reporting }}"
  212. # Set MTU for tunnel device used if ipip is enabled
  213. {% if calico_mtu is defined %}
  214. - name: FELIX_IPINIPMTU
  215. value: "{{ calico_veth_mtu | default(calico_mtu) }}"
  216. {% endif %}
  217. - name: FELIX_CHAININSERTMODE
  218. value: "{{ calico_felix_chaininsertmode }}"
  219. - name: FELIX_PROMETHEUSMETRICSENABLED
  220. value: "{{ calico_felix_prometheusmetricsenabled }}"
  221. - name: FELIX_PROMETHEUSMETRICSPORT
  222. value: "{{ calico_felix_prometheusmetricsport }}"
  223. - name: FELIX_PROMETHEUSGOMETRICSENABLED
  224. value: "{{ calico_felix_prometheusgometricsenabled }}"
  225. - name: FELIX_PROMETHEUSPROCESSMETRICSENABLED
  226. value: "{{ calico_felix_prometheusprocessmetricsenabled }}"
  227. {% if calico_advertise_cluster_ips|default(false) %}
  228. - name: CALICO_ADVERTISE_CLUSTER_IPS
  229. value: "{{ kube_service_addresses }}"
  230. {% endif %}
  231. {% if calico_ip_auto_method is defined %}
  232. - name: IP_AUTODETECTION_METHOD
  233. value: "{{ calico_ip_auto_method }}"
  234. - name: IP
  235. value: "autodetect"
  236. {% else %}
  237. - name: IP
  238. valueFrom:
  239. fieldRef:
  240. fieldPath: status.hostIP
  241. {% endif %}
  242. {% if calico_use_default_route_src_ipaddr|default(false) %}
  243. - name: FELIX_DEVICEROUTESOURCEADDRESS
  244. valueFrom:
  245. fieldRef:
  246. fieldPath: status.hostIP
  247. {% endif %}
  248. - name: NODENAME
  249. valueFrom:
  250. fieldRef:
  251. fieldPath: spec.nodeName
  252. - name: FELIX_HEALTHENABLED
  253. value: "true"
  254. - name: FELIX_IGNORELOOSERPF
  255. value: "{{ calico_node_ignorelooserpf }}"
  256. {% if calico_node_extra_envs is defined %}
  257. {% for key in calico_node_extra_envs %}
  258. - name: {{ key }}
  259. value: "{{ calico_node_extra_envs[key] }}"
  260. {% endfor %}
  261. {% endif %}
  262. securityContext:
  263. privileged: true
  264. resources:
  265. limits:
  266. cpu: {{ calico_node_cpu_limit }}
  267. memory: {{ calico_node_memory_limit }}
  268. requests:
  269. cpu: {{ calico_node_cpu_requests }}
  270. memory: {{ calico_node_memory_requests }}
  271. livenessProbe:
  272. exec:
  273. command:
  274. - /bin/calico-node
  275. - -felix-live
  276. {% if calico_network_backend|default("bird") == "bird" %}
  277. - -bird-live
  278. {% endif %}
  279. initialDelaySeconds: 5
  280. failureThreshold: 6
  281. readinessProbe:
  282. failureThreshold: 6
  283. exec:
  284. command:
  285. - /bin/calico-node
  286. {% if calico_network_backend|default("bird") == "bird" %}
  287. - -bird-ready
  288. {% endif %}
  289. - -felix-ready
  290. volumeMounts:
  291. - mountPath: /lib/modules
  292. name: lib-modules
  293. readOnly: true
  294. - mountPath: /var/run/calico
  295. name: var-run-calico
  296. - mountPath: /var/lib/calico
  297. name: var-lib-calico
  298. readOnly: false
  299. {% if calico_datastore == "etcd" %}
  300. - mountPath: /calico-secrets
  301. name: etcd-certs
  302. {% endif %}
  303. - name: xtables-lock
  304. mountPath: /run/xtables.lock
  305. readOnly: false
  306. {% if typha_secure %}
  307. - name: typha-client
  308. mountPath: /etc/typha-client
  309. readOnly: true
  310. - name: typha-cacert
  311. subPath: ca.crt
  312. mountPath: /etc/typha-ca/ca.crt
  313. readOnly: true
  314. {% endif %}
  315. volumes:
  316. # Used by calico/node.
  317. - name: lib-modules
  318. hostPath:
  319. path: /lib/modules
  320. - name: var-run-calico
  321. hostPath:
  322. path: /var/run/calico
  323. - name: var-lib-calico
  324. hostPath:
  325. path: /var/lib/calico
  326. # Used to install CNI.
  327. - name: cni-net-dir
  328. hostPath:
  329. path: /etc/cni/net.d
  330. - name: cni-bin-dir
  331. hostPath:
  332. path: /opt/cni/bin
  333. {% if calico_datastore == "etcd" %}
  334. # Mount in the etcd TLS secrets.
  335. - name: etcd-certs
  336. hostPath:
  337. path: "{{ calico_cert_dir }}"
  338. {% endif %}
  339. # Mount the global iptables lock file, used by calico/node
  340. - name: xtables-lock
  341. hostPath:
  342. path: /run/xtables.lock
  343. type: FileOrCreate
  344. {% if calico_datastore == "kdd" %}
  345. # Mount in the directory for host-local IPAM allocations. This is
  346. # used when upgrading from host-local to calico-ipam, and can be removed
  347. # if not using the upgrade-ipam init container.
  348. - name: host-local-net-dir
  349. hostPath:
  350. path: /var/lib/cni/networks
  351. {% endif %}
  352. {% if typha_enabled and typha_secure %}
  353. - name: typha-client
  354. secret:
  355. secretName: typha-client
  356. items:
  357. - key: tls.crt
  358. path: typha-client.crt
  359. - key: tls.key
  360. path: typha-client.key
  361. - name: typha-cacert
  362. hostPath:
  363. path: "/etc/kubernetes/ssl/"
  364. {% endif %}
  365. updateStrategy:
  366. rollingUpdate:
  367. maxUnavailable: {{ serial | default('20%') }}
  368. type: RollingUpdate