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.

375 lines
14 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. - name: FELIX_IPV6SUPPORT
  204. value: "{{ enable_dual_stack_networks | default(false) }}"
  205. # Set Felix logging to "info"
  206. - name: FELIX_LOGSEVERITYSCREEN
  207. value: "{{ calico_loglevel }}"
  208. # Set Calico startup logging to "error"
  209. - name: CALICO_STARTUP_LOGLEVEL
  210. value: "{{ calico_node_startup_loglevel }}"
  211. # Enable or disable usage report
  212. - name: FELIX_USAGEREPORTINGENABLED
  213. value: "{{ calico_usage_reporting }}"
  214. # Set MTU for tunnel device used if ipip is enabled
  215. {% if calico_mtu is defined %}
  216. - name: FELIX_IPINIPMTU
  217. value: "{{ calico_veth_mtu | default(calico_mtu) }}"
  218. {% endif %}
  219. - name: FELIX_CHAININSERTMODE
  220. value: "{{ calico_felix_chaininsertmode }}"
  221. - name: FELIX_PROMETHEUSMETRICSENABLED
  222. value: "{{ calico_felix_prometheusmetricsenabled }}"
  223. - name: FELIX_PROMETHEUSMETRICSPORT
  224. value: "{{ calico_felix_prometheusmetricsport }}"
  225. - name: FELIX_PROMETHEUSGOMETRICSENABLED
  226. value: "{{ calico_felix_prometheusgometricsenabled }}"
  227. - name: FELIX_PROMETHEUSPROCESSMETRICSENABLED
  228. value: "{{ calico_felix_prometheusprocessmetricsenabled }}"
  229. {% if calico_ip_auto_method is defined %}
  230. - name: IP_AUTODETECTION_METHOD
  231. value: "{{ calico_ip_auto_method }}"
  232. - name: IP
  233. value: "autodetect"
  234. {% else %}
  235. - name: NODEIP
  236. valueFrom:
  237. fieldRef:
  238. fieldPath: status.hostIP
  239. - name: IP_AUTODETECTION_METHOD
  240. value: "can-reach=$(NODEIP)"
  241. - name: IP
  242. value: "autodetect"
  243. {% endif %}
  244. {% if enable_dual_stack_networks %}
  245. - name: IP6
  246. value: autodetect
  247. {% endif %}
  248. {% if calico_use_default_route_src_ipaddr|default(false) %}
  249. - name: FELIX_DEVICEROUTESOURCEADDRESS
  250. valueFrom:
  251. fieldRef:
  252. fieldPath: status.hostIP
  253. {% endif %}
  254. - name: NODENAME
  255. valueFrom:
  256. fieldRef:
  257. fieldPath: spec.nodeName
  258. - name: FELIX_HEALTHENABLED
  259. value: "true"
  260. - name: FELIX_IGNORELOOSERPF
  261. value: "{{ calico_node_ignorelooserpf }}"
  262. {% if calico_node_extra_envs is defined %}
  263. {% for key in calico_node_extra_envs %}
  264. - name: {{ key }}
  265. value: "{{ calico_node_extra_envs[key] }}"
  266. {% endfor %}
  267. {% endif %}
  268. securityContext:
  269. privileged: true
  270. resources:
  271. limits:
  272. cpu: {{ calico_node_cpu_limit }}
  273. memory: {{ calico_node_memory_limit }}
  274. requests:
  275. cpu: {{ calico_node_cpu_requests }}
  276. memory: {{ calico_node_memory_requests }}
  277. livenessProbe:
  278. exec:
  279. command:
  280. - /bin/calico-node
  281. - -felix-live
  282. {% if calico_network_backend|default("bird") == "bird" %}
  283. - -bird-live
  284. {% endif %}
  285. initialDelaySeconds: 5
  286. failureThreshold: 6
  287. readinessProbe:
  288. failureThreshold: 6
  289. exec:
  290. command:
  291. - /bin/calico-node
  292. {% if calico_network_backend|default("bird") == "bird" %}
  293. - -bird-ready
  294. {% endif %}
  295. - -felix-ready
  296. volumeMounts:
  297. - mountPath: /lib/modules
  298. name: lib-modules
  299. readOnly: true
  300. - mountPath: /var/run/calico
  301. name: var-run-calico
  302. - mountPath: /var/lib/calico
  303. name: var-lib-calico
  304. readOnly: false
  305. {% if calico_datastore == "etcd" %}
  306. - mountPath: /calico-secrets
  307. name: etcd-certs
  308. {% endif %}
  309. - name: xtables-lock
  310. mountPath: /run/xtables.lock
  311. readOnly: false
  312. {% if typha_secure %}
  313. - name: typha-client
  314. mountPath: /etc/typha-client
  315. readOnly: true
  316. - name: typha-cacert
  317. subPath: ca.crt
  318. mountPath: /etc/typha-ca/ca.crt
  319. readOnly: true
  320. {% endif %}
  321. volumes:
  322. # Used by calico/node.
  323. - name: lib-modules
  324. hostPath:
  325. path: /lib/modules
  326. - name: var-run-calico
  327. hostPath:
  328. path: /var/run/calico
  329. - name: var-lib-calico
  330. hostPath:
  331. path: /var/lib/calico
  332. # Used to install CNI.
  333. - name: cni-net-dir
  334. hostPath:
  335. path: /etc/cni/net.d
  336. - name: cni-bin-dir
  337. hostPath:
  338. path: /opt/cni/bin
  339. {% if calico_datastore == "etcd" %}
  340. # Mount in the etcd TLS secrets.
  341. - name: etcd-certs
  342. hostPath:
  343. path: "{{ calico_cert_dir }}"
  344. {% endif %}
  345. # Mount the global iptables lock file, used by calico/node
  346. - name: xtables-lock
  347. hostPath:
  348. path: /run/xtables.lock
  349. type: FileOrCreate
  350. {% if calico_datastore == "kdd" %}
  351. # Mount in the directory for host-local IPAM allocations. This is
  352. # used when upgrading from host-local to calico-ipam, and can be removed
  353. # if not using the upgrade-ipam init container.
  354. - name: host-local-net-dir
  355. hostPath:
  356. path: /var/lib/cni/networks
  357. {% endif %}
  358. {% if typha_enabled and typha_secure %}
  359. - name: typha-client
  360. secret:
  361. secretName: typha-client
  362. items:
  363. - key: tls.crt
  364. path: typha-client.crt
  365. - key: tls.key
  366. path: typha-client.key
  367. - name: typha-cacert
  368. hostPath:
  369. path: "/etc/kubernetes/ssl/"
  370. {% endif %}
  371. updateStrategy:
  372. rollingUpdate:
  373. maxUnavailable: {{ serial | default('20%') }}
  374. type: RollingUpdate