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.

254 lines
8.4 KiB

  1. ---
  2. kind: DaemonSet
  3. apiVersion: apps/v1
  4. metadata:
  5. name: canal-node
  6. namespace: kube-system
  7. labels:
  8. k8s-app: canal-node
  9. spec:
  10. selector:
  11. matchLabels:
  12. k8s-app: canal-node
  13. template:
  14. metadata:
  15. labels:
  16. k8s-app: canal-node
  17. spec:
  18. priorityClassName: system-node-critical
  19. hostNetwork: true
  20. dnsPolicy: ClusterFirstWithHostNet
  21. serviceAccountName: canal
  22. tolerations:
  23. - operator: Exists
  24. volumes:
  25. # Used by calico/node.
  26. - name: lib-modules
  27. hostPath:
  28. path: /lib/modules
  29. - name: var-lib-calico
  30. hostPath:
  31. path: /var/lib/calico
  32. - name: var-run-calico
  33. hostPath:
  34. path: /var/run/calico
  35. # Used to install CNI.
  36. - name: cni-bin-dir
  37. hostPath:
  38. path: /opt/cni/bin
  39. - name: cni-net-dir
  40. hostPath:
  41. path: /etc/cni/net.d
  42. # Used by flannel daemon.
  43. - name: run-flannel
  44. hostPath:
  45. path: /run/flannel
  46. - name: resolv
  47. hostPath:
  48. path: /etc/resolv.conf
  49. - name: "canal-certs"
  50. hostPath:
  51. path: "{{ canal_cert_dir }}"
  52. - name: xtables-lock
  53. hostPath:
  54. path: /run/xtables.lock
  55. type: FileOrCreate
  56. initContainers:
  57. # This container installs the Calico CNI binaries
  58. # and CNI network config file on each node.
  59. - name: install-cni
  60. image: {{ calico_cni_image_repo }}:{{ calico_cni_image_tag }}
  61. command: ["/opt/cni/bin/install"]
  62. env:
  63. # Name of the CNI config file to create.
  64. - name: CNI_CONF_NAME
  65. value: "10-canal.conflist"
  66. # Install CNI binaries
  67. - name: UPDATE_CNI_BINARIES
  68. value: "true"
  69. # The CNI network config to install on each node.
  70. - name: CNI_NETWORK_CONFIG_FILE
  71. value: "/host/etc/cni/net.d/canal.conflist.template"
  72. # Prevents the container from sleeping forever.
  73. - name: SLEEP
  74. value: "false"
  75. volumeMounts:
  76. - mountPath: /host/etc/cni/net.d
  77. name: cni-net-dir
  78. - mountPath: /host/opt/cni/bin
  79. name: cni-bin-dir
  80. containers:
  81. # Runs the flannel daemon to enable vxlan networking between
  82. # container hosts.
  83. - name: flannel
  84. image: "{{ flannel_image_repo }}:{{ flannel_image_tag }}"
  85. imagePullPolicy: {{ k8s_image_pull_policy }}
  86. resources:
  87. limits:
  88. cpu: {{ flannel_cpu_limit }}
  89. memory: {{ flannel_memory_limit }}
  90. requests:
  91. cpu: {{ flannel_cpu_requests }}
  92. memory: {{ flannel_memory_requests }}
  93. env:
  94. # Cluster name
  95. - name: CLUSTER_NAME
  96. valueFrom:
  97. configMapKeyRef:
  98. name: canal-config
  99. key: cluster_name
  100. # The location of the etcd cluster.
  101. - name: FLANNELD_ETCD_ENDPOINTS
  102. valueFrom:
  103. configMapKeyRef:
  104. name: canal-config
  105. key: etcd_endpoints
  106. # The interface flannel should run on.
  107. - name: FLANNELD_IFACE
  108. valueFrom:
  109. configMapKeyRef:
  110. name: canal-config
  111. key: flanneld_iface
  112. # Perform masquerade on traffic leaving the pod cidr.
  113. - name: FLANNELD_IP_MASQ
  114. valueFrom:
  115. configMapKeyRef:
  116. name: canal-config
  117. key: masquerade
  118. # Set etcd-prefix
  119. - name: DOCKER_OPT_ETCD_PREFIX
  120. value: "-etcd-prefix=/$(CLUSTER_NAME)/network"
  121. # Write the subnet.env file to the mounted directory.
  122. - name: FLANNELD_SUBNET_FILE
  123. value: "/run/flannel/subnet.env"
  124. # Etcd SSL vars
  125. - name: ETCD_CA_CERT_FILE
  126. valueFrom:
  127. configMapKeyRef:
  128. name: canal-config
  129. key: etcd_cafile
  130. - name: ETCD_CERT_FILE
  131. valueFrom:
  132. configMapKeyRef:
  133. name: canal-config
  134. key: etcd_certfile
  135. - name: ETCD_KEY_FILE
  136. valueFrom:
  137. configMapKeyRef:
  138. name: canal-config
  139. key: etcd_keyfile
  140. command:
  141. - "/bin/sh"
  142. - "-c"
  143. - "/opt/bin/flanneld -etcd-prefix /$(CLUSTER_NAME)/network -etcd-cafile $(ETCD_CA_CERT_FILE) -etcd-certfile $(ETCD_CERT_FILE) -etcd-keyfile $(ETCD_KEY_FILE)"
  144. ports:
  145. - hostPort: 10253
  146. containerPort: 10253
  147. securityContext:
  148. privileged: true
  149. volumeMounts:
  150. - name: "resolv"
  151. mountPath: "/etc/resolv.conf"
  152. - name: "run-flannel"
  153. mountPath: "/run/flannel"
  154. - name: "canal-certs"
  155. mountPath: "{{ canal_cert_dir }}"
  156. readOnly: true
  157. - name: xtables-lock
  158. mountPath: /run/xtables.lock
  159. readOnly: false
  160. # Runs calico/node container on each Kubernetes node. This
  161. # container programs network policy and local routes on each
  162. # host.
  163. - name: calico-node
  164. image: "{{ calico_node_image_repo }}:{{ calico_node_image_tag }}"
  165. imagePullPolicy: {{ k8s_image_pull_policy }}
  166. resources:
  167. limits:
  168. cpu: {{ calico_node_cpu_limit }}
  169. memory: {{ calico_node_memory_limit }}
  170. requests:
  171. cpu: {{ calico_node_cpu_requests }}
  172. memory: {{ calico_node_memory_requests }}
  173. env:
  174. # The location of the etcd cluster.
  175. - name: ETCD_ENDPOINTS
  176. valueFrom:
  177. configMapKeyRef:
  178. name: canal-config
  179. key: etcd_endpoints
  180. # Disable Calico BGP. Calico is simply enforcing policy.
  181. - name: CALICO_NETWORKING_BACKEND
  182. value: "none"
  183. # Cluster type to identify the deployment type
  184. - name: CLUSTER_TYPE
  185. value: "kubespray,canal"
  186. # Disable file logging so `kubectl logs` works.
  187. - name: CALICO_DISABLE_FILE_LOGGING
  188. value: "true"
  189. # Set noderef for node controller.
  190. - name: CALICO_K8S_NODE_REF
  191. valueFrom:
  192. fieldRef:
  193. fieldPath: spec.nodeName
  194. - name: FELIX_HEALTHENABLED
  195. value: "true"
  196. # Disable IPv6 on Kubernetes.
  197. - name: FELIX_IPV6SUPPORT
  198. value: "false"
  199. # Etcd SSL vars
  200. - name: ETCD_CA_CERT_FILE
  201. valueFrom:
  202. configMapKeyRef:
  203. name: canal-config
  204. key: etcd_cafile
  205. - name: ETCD_CERT_FILE
  206. valueFrom:
  207. configMapKeyRef:
  208. name: canal-config
  209. key: etcd_certfile
  210. - name: ETCD_KEY_FILE
  211. valueFrom:
  212. configMapKeyRef:
  213. name: canal-config
  214. key: etcd_keyfile
  215. - name: NODENAME
  216. valueFrom:
  217. fieldRef:
  218. fieldPath: spec.nodeName
  219. securityContext:
  220. privileged: true
  221. livenessProbe:
  222. httpGet:
  223. host: 127.0.0.1
  224. path: /liveness
  225. port: 9099
  226. periodSeconds: 10
  227. initialDelaySeconds: 5
  228. failureThreshold: 6
  229. readinessProbe:
  230. exec:
  231. command:
  232. - /bin/calico-node
  233. - -felix-ready
  234. periodSeconds: 10
  235. volumeMounts:
  236. - mountPath: /lib/modules
  237. name: lib-modules
  238. readOnly: true
  239. - mountPath: /var/run/calico
  240. name: var-run-calico
  241. readOnly: false
  242. - mountPath: /var/lib/calico
  243. name: var-lib-calico
  244. readOnly: false
  245. - name: "canal-certs"
  246. mountPath: "{{ canal_cert_dir }}"
  247. readOnly: true
  248. - name: xtables-lock
  249. mountPath: /run/xtables.lock
  250. readOnly: false
  251. updateStrategy:
  252. rollingUpdate:
  253. maxUnavailable: {{ serial | default('20%') }}
  254. type: RollingUpdate