calico.yml.j2 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. ---
  2. kind: ClusterRole
  3. apiVersion: v1
  4. metadata:
  5. name: calico-kube-controllers
  6. namespace: kube-system
  7. rules:
  8. - apiGroups:
  9. - ""
  10. - extensions
  11. resources:
  12. - pods
  13. - namespaces
  14. - networkpolicies
  15. - nodes
  16. verbs:
  17. - watch
  18. - list
  19. ---
  20. kind: ClusterRoleBinding
  21. apiVersion: v1
  22. metadata:
  23. name: calico-kube-controllers
  24. roleRef:
  25. apiGroup: rbac.authorization.k8s.io
  26. kind: ClusterRole
  27. name: calico-kube-controllers
  28. subjects:
  29. - kind: ServiceAccount
  30. name: calico-kube-controllers
  31. namespace: kube-system
  32. ---
  33. kind: ClusterRole
  34. apiVersion: v1
  35. metadata:
  36. name: calico-node
  37. namespace: kube-system
  38. rules:
  39. - apiGroups: [""]
  40. resources:
  41. - pods
  42. - nodes
  43. verbs:
  44. - get
  45. ---
  46. apiVersion: v1
  47. kind: ClusterRoleBinding
  48. metadata:
  49. name: calico-node
  50. roleRef:
  51. apiGroup: rbac.authorization.k8s.io
  52. kind: ClusterRole
  53. name: calico-node
  54. subjects:
  55. - kind: ServiceAccount
  56. name: calico-node
  57. namespace: kube-system
  58. ---
  59. # This ConfigMap is used to configure a self-hosted Calico installation.
  60. kind: ConfigMap
  61. apiVersion: v1
  62. metadata:
  63. name: calico-config
  64. namespace: kube-system
  65. data:
  66. # Configure this with the location of your etcd cluster.
  67. etcd_endpoints: "{{ calico_etcd_endpoints }}"
  68. # Configure the Calico backend to use.
  69. calico_backend: "bird"
  70. # The CNI network configuration to install on each node.
  71. cni_network_config: |-
  72. {
  73. "name": "k8s-pod-network",
  74. "cniVersion": "0.1.0",
  75. "type": "calico",
  76. "etcd_endpoints": "__ETCD_ENDPOINTS__",
  77. "etcd_key_file": "__ETCD_KEY_FILE__",
  78. "etcd_cert_file": "__ETCD_CERT_FILE__",
  79. "etcd_ca_cert_file": "__ETCD_CA_CERT_FILE__",
  80. "log_level": "info",
  81. "mtu": 1500,
  82. "ipam": {
  83. "type": "calico-ipam"
  84. },
  85. "policy": {
  86. "type": "k8s",
  87. "k8s_api_root": "https://__KUBERNETES_SERVICE_HOST__:__KUBERNETES_SERVICE_PORT__",
  88. "k8s_auth_token": "__SERVICEACCOUNT_TOKEN__"
  89. },
  90. "kubernetes": {
  91. "kubeconfig": "__KUBECONFIG_FILEPATH__"
  92. }
  93. }
  94. etcd_ca: "/calico-secrets/etcd-ca"
  95. etcd_cert: "/calico-secrets/etcd-cert"
  96. etcd_key: "/calico-secrets/etcd-key"
  97. ---
  98. # This manifest installs the calico/node container, as well
  99. # as the Calico CNI plugins and network config on
  100. # each master and worker node in a Kubernetes cluster.
  101. kind: DaemonSet
  102. apiVersion: extensions/v1beta1
  103. metadata:
  104. name: calico-node
  105. namespace: kube-system
  106. labels:
  107. k8s-app: calico-node
  108. spec:
  109. updateStrategy:
  110. type: RollingUpdate
  111. rollingUpdate:
  112. maxUnavailable: 1
  113. selector:
  114. matchLabels:
  115. k8s-app: calico-node
  116. template:
  117. metadata:
  118. labels:
  119. k8s-app: calico-node
  120. annotations:
  121. scheduler.alpha.kubernetes.io/critical-pod: ''
  122. spec:
  123. hostNetwork: true
  124. tolerations:
  125. # Make sure calico/node gets scheduled on all nodes.
  126. - effect: NoSchedule
  127. operator: Exists
  128. # Mark the pod as a critical add-on for rescheduling.
  129. - key: CriticalAddonsOnly
  130. operator: Exists
  131. - effect: NoExecute
  132. operator: Exists
  133. serviceAccountName: calico-node
  134. # Minimize downtime during a rolling upgrade or deletion; tell Kubernetes to do a "force
  135. # deletion": https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods.
  136. terminationGracePeriodSeconds: 0
  137. containers:
  138. # Runs calico/node container on each Kubernetes node. This
  139. # container programs network policy and routes on each
  140. # host.
  141. - name: calico-node
  142. image: {{ calico_node_image }}
  143. env:
  144. # The location of the Calico etcd cluster.
  145. - name: ETCD_ENDPOINTS
  146. valueFrom:
  147. configMapKeyRef:
  148. name: calico-config
  149. key: etcd_endpoints
  150. # Choose the backend to use.
  151. - name: CALICO_NETWORKING_BACKEND
  152. valueFrom:
  153. configMapKeyRef:
  154. name: calico-config
  155. key: calico_backend
  156. # Cluster type to identify the deployment type
  157. - name: CLUSTER_TYPE
  158. value: "origin,bgp"
  159. # Disable file logging so `kubectl logs` works.
  160. - name: CALICO_DISABLE_FILE_LOGGING
  161. value: "true"
  162. # Set noderef for node controller.
  163. - name: CALICO_K8S_NODE_REF
  164. valueFrom:
  165. fieldRef:
  166. fieldPath: spec.nodeName
  167. # Set Felix endpoint to host default action to ACCEPT.
  168. - name: FELIX_DEFAULTENDPOINTTOHOSTACTION
  169. value: "ACCEPT"
  170. # Configure the IP Pool from which Pod IPs will be chosen.
  171. - name: CALICO_IPV4POOL_CIDR
  172. value: "{{ openshift_cluster_network_cidr }}"
  173. - name: CALICO_IPV4POOL_IPIP
  174. value: "{{ calico_ipv4pool_ipip }}"
  175. # Disable IPv6 on Kubernetes.
  176. - name: FELIX_IPV6SUPPORT
  177. value: "false"
  178. # Set Felix logging to "info"
  179. - name: FELIX_LOGSEVERITYSCREEN
  180. value: "info"
  181. # Set MTU for tunnel device used if ipip is enabled
  182. - name: FELIX_IPINIPMTU
  183. value: "1440"
  184. - name: ETCD_ENDPOINTS
  185. valueFrom:
  186. configMapKeyRef:
  187. name: calico-config
  188. key: etcd_endpoints
  189. # Location of the CA certificate for etcd.
  190. - name: ETCD_CA_CERT_FILE
  191. valueFrom:
  192. configMapKeyRef:
  193. name: calico-config
  194. key: etcd_ca
  195. # Location of the client key for etcd.
  196. - name: ETCD_KEY_FILE
  197. valueFrom:
  198. configMapKeyRef:
  199. name: calico-config
  200. key: etcd_key
  201. # Location of the client certificate for etcd.
  202. - name: ETCD_CERT_FILE
  203. valueFrom:
  204. configMapKeyRef:
  205. name: calico-config
  206. key: etcd_cert
  207. # Auto-detect the BGP IP address.
  208. - name: IP
  209. value: ""
  210. - name: FELIX_HEALTHENABLED
  211. value: "true"
  212. securityContext:
  213. privileged: true
  214. livenessProbe:
  215. httpGet:
  216. path: /liveness
  217. port: 9099
  218. periodSeconds: 10
  219. initialDelaySeconds: 10
  220. failureThreshold: 6
  221. readinessProbe:
  222. httpGet:
  223. path: /readiness
  224. port: 9099
  225. periodSeconds: 10
  226. volumeMounts:
  227. - mountPath: /lib/modules
  228. name: lib-modules
  229. readOnly: true
  230. - mountPath: /var/run/calico
  231. name: var-run-calico
  232. readOnly: false
  233. - mountPath: /calico-secrets
  234. name: etcd-certs
  235. # This container installs the Calico CNI binaries
  236. # and CNI network config file on each node.
  237. - name: install-cni
  238. securityContext:
  239. privileged: true
  240. image: {{ calico_cni_image }}
  241. command: ["/install-cni.sh"]
  242. env:
  243. # The location of the Calico etcd cluster.
  244. - name: ETCD_ENDPOINTS
  245. valueFrom:
  246. configMapKeyRef:
  247. name: calico-config
  248. key: etcd_endpoints
  249. # The CNI network config to install on each node.
  250. - name: CNI_NETWORK_CONFIG
  251. valueFrom:
  252. configMapKeyRef:
  253. name: calico-config
  254. key: cni_network_config
  255. # Location of the CA certificate for etcd.
  256. - name: CNI_CONF_ETCD_CA
  257. valueFrom:
  258. configMapKeyRef:
  259. name: calico-config
  260. key: etcd_ca
  261. # Location of the client key for etcd.
  262. - name: CNI_CONF_ETCD_KEY
  263. valueFrom:
  264. configMapKeyRef:
  265. name: calico-config
  266. key: etcd_key
  267. # Location of the client certificate for etcd.
  268. - name: CNI_CONF_ETCD_CERT
  269. valueFrom:
  270. configMapKeyRef:
  271. name: calico-config
  272. key: etcd_cert
  273. volumeMounts:
  274. - mountPath: /host/opt/cni/bin
  275. name: cni-bin-dir
  276. - mountPath: /host/etc/cni/net.d
  277. name: cni-net-dir
  278. - mountPath: /calico-secrets
  279. name: etcd-certs
  280. volumes:
  281. # Used by calico/node.
  282. - name: lib-modules
  283. hostPath:
  284. path: /lib/modules
  285. - name: var-run-calico
  286. hostPath:
  287. path: /var/run/calico
  288. # Used to install CNI.
  289. - name: cni-bin-dir
  290. hostPath:
  291. path: {{ cni_bin_dir }}
  292. - name: cni-net-dir
  293. hostPath:
  294. path: {{ cni_conf_dir }}
  295. # Mount in the etcd TLS secrets.
  296. - name: etcd-certs
  297. secret:
  298. secretName: calico-etcd-secrets
  299. ---
  300. # This manifest deploys the Calico Kubernetes controllers.
  301. # See https://github.com/projectcalico/kube-controllers
  302. apiVersion: extensions/v1beta1
  303. kind: Deployment
  304. metadata:
  305. name: calico-kube-controllers
  306. namespace: kube-system
  307. labels:
  308. k8s-app: calico-kube-controllers
  309. annotations:
  310. scheduler.alpha.kubernetes.io/critical-pod: ''
  311. spec:
  312. # The controllers can only have a single active instance.
  313. replicas: 1
  314. strategy:
  315. type: Recreate
  316. template:
  317. metadata:
  318. name: calico-kube-controllers
  319. namespace: kube-system
  320. labels:
  321. k8s-app: calico-kube-controllers
  322. spec:
  323. # The controllers must run in the host network namespace so that
  324. # it isn't governed by policy that would prevent it from working.
  325. hostNetwork: true
  326. tolerations:
  327. # Mark the pod as a critical add-on for rescheduling.
  328. - key: CriticalAddonsOnly
  329. operator: Exists
  330. - key: node-role.kubernetes.io/master
  331. effect: NoSchedule
  332. serviceAccountName: calico-kube-controllers
  333. containers:
  334. - name: calico-kube-controllers
  335. securityContext:
  336. privileged: true
  337. image: {{ calico_url_policy_controller }}
  338. env:
  339. # The location of the Calico etcd cluster.
  340. - name: ETCD_ENDPOINTS
  341. valueFrom:
  342. configMapKeyRef:
  343. name: calico-config
  344. key: etcd_endpoints
  345. # Location of the CA certificate for etcd.
  346. - name: ETCD_CA_CERT_FILE
  347. valueFrom:
  348. configMapKeyRef:
  349. name: calico-config
  350. key: etcd_ca
  351. # Location of the client key for etcd.
  352. - name: ETCD_KEY_FILE
  353. valueFrom:
  354. configMapKeyRef:
  355. name: calico-config
  356. key: etcd_key
  357. # Location of the client certificate for etcd.
  358. - name: ETCD_CERT_FILE
  359. valueFrom:
  360. configMapKeyRef:
  361. name: calico-config
  362. key: etcd_cert
  363. # Choose which controllers to run.
  364. - name: ENABLED_CONTROLLERS
  365. value: policy,profile,workloadendpoint,node
  366. volumeMounts:
  367. # Mount in the etcd TLS secrets.
  368. - mountPath: /calico-secrets
  369. name: etcd-certs
  370. volumes:
  371. # Mount in the etcd TLS secrets.
  372. - name: etcd-certs
  373. secret:
  374. secretName: calico-etcd-secrets
  375. ---
  376. apiVersion: v1
  377. kind: ServiceAccount
  378. metadata:
  379. name: calico-kube-controllers
  380. namespace: kube-system
  381. ---
  382. apiVersion: v1
  383. kind: ServiceAccount
  384. metadata:
  385. name: calico-node
  386. namespace: kube-system