calicov3.yml.j2 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  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. - apiGroups:
  20. - networking.k8s.io
  21. resources:
  22. - networkpolicies
  23. verbs:
  24. - watch
  25. - list
  26. ---
  27. kind: ClusterRoleBinding
  28. apiVersion: v1
  29. metadata:
  30. name: calico-kube-controllers
  31. roleRef:
  32. apiGroup: rbac.authorization.k8s.io
  33. kind: ClusterRole
  34. name: calico-kube-controllers
  35. subjects:
  36. - kind: ServiceAccount
  37. name: calico-kube-controllers
  38. namespace: kube-system
  39. ---
  40. kind: ClusterRole
  41. apiVersion: v1
  42. metadata:
  43. name: calico-node
  44. namespace: kube-system
  45. rules:
  46. - apiGroups: [""]
  47. resources:
  48. - pods
  49. - nodes
  50. verbs:
  51. - get
  52. ---
  53. apiVersion: v1
  54. kind: ClusterRoleBinding
  55. metadata:
  56. name: calico-node
  57. roleRef:
  58. apiGroup: rbac.authorization.k8s.io
  59. kind: ClusterRole
  60. name: calico-node
  61. subjects:
  62. - kind: ServiceAccount
  63. name: calico-node
  64. namespace: kube-system
  65. ---
  66. kind: ClusterRole
  67. apiVersion: v1
  68. metadata:
  69. name: calico-upgrade-job
  70. namespace: kube-system
  71. rules:
  72. - apiGroups:
  73. - extensions
  74. resources:
  75. - daemonsets
  76. verbs:
  77. - get
  78. - list
  79. - watch
  80. ---
  81. apiVersion: v1
  82. kind: ClusterRoleBinding
  83. metadata:
  84. name: calico-upgrade-job
  85. roleRef:
  86. apiGroup: rbac.authorization.k8s.io
  87. kind: ClusterRole
  88. name: calico-upgrade-job
  89. subjects:
  90. - kind: ServiceAccount
  91. name: calico-upgrade-job
  92. namespace: kube-system
  93. ---
  94. # This ConfigMap is used to configure a self-hosted Calico installation.
  95. kind: ConfigMap
  96. apiVersion: v1
  97. metadata:
  98. name: calico-config
  99. namespace: kube-system
  100. data:
  101. # Configure this with the location of your etcd cluster.
  102. etcd_endpoints: "{{ calico_etcd_endpoints }}"
  103. node_image: "{{ calico_node_image }}"
  104. # Configure the Calico backend to use.
  105. calico_backend: "bird"
  106. # The CNI network configuration to install on each node.
  107. cni_network_config: |-
  108. {
  109. "name": "k8s-pod-network",
  110. "cniVersion": "0.3.0",
  111. "plugins": [
  112. {
  113. "type": "calico",
  114. "etcd_endpoints": "__ETCD_ENDPOINTS__",
  115. "etcd_key_file": "__ETCD_KEY_FILE__",
  116. "etcd_cert_file": "__ETCD_CERT_FILE__",
  117. "etcd_ca_cert_file": "__ETCD_CA_CERT_FILE__",
  118. "log_level": "info",
  119. "mtu": 1500,
  120. "ipam": {
  121. "type": "calico-ipam"
  122. },
  123. "policy": {
  124. "type": "k8s"
  125. },
  126. "kubernetes": {
  127. "kubeconfig": "__KUBECONFIG_FILEPATH__"
  128. }
  129. },
  130. {
  131. "type": "portmap",
  132. "snat": true,
  133. "capabilities": {"portMappings": true}
  134. }
  135. ]
  136. }
  137. # If you're using TLS enabled etcd uncomment the following.
  138. # You must also populate the Secret below with these files.
  139. etcd_ca: "/calico-secrets/etcd-ca"
  140. etcd_cert: "/calico-secrets/etcd-cert"
  141. etcd_key: "/calico-secrets/etcd-key"
  142. ---
  143. # This manifest installs the calico/node container, as well
  144. # as the Calico CNI plugins and network config on
  145. # each master and worker node in a Kubernetes cluster.
  146. kind: DaemonSet
  147. apiVersion: extensions/v1beta1
  148. metadata:
  149. name: calico-node
  150. namespace: kube-system
  151. labels:
  152. k8s-app: calico-node
  153. spec:
  154. selector:
  155. matchLabels:
  156. k8s-app: calico-node
  157. updateStrategy:
  158. type: RollingUpdate
  159. rollingUpdate:
  160. maxUnavailable: 1
  161. template:
  162. metadata:
  163. labels:
  164. k8s-app: calico-node
  165. annotations:
  166. scheduler.alpha.kubernetes.io/critical-pod: ''
  167. spec:
  168. {% if calico_image_credentials is defined %}
  169. imagePullSecrets:
  170. - name: calico-pull-secret
  171. {% endif %}
  172. hostNetwork: true
  173. tolerations:
  174. # Make sure calico/node gets scheduled on all nodes.
  175. - effect: NoSchedule
  176. operator: Exists
  177. # Mark the pod as a critical add-on for rescheduling.
  178. - key: CriticalAddonsOnly
  179. operator: Exists
  180. - effect: NoExecute
  181. operator: Exists
  182. serviceAccountName: calico-node
  183. # Minimize downtime during a rolling upgrade or deletion; tell Kubernetes to do a "force
  184. # deletion": https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods.
  185. terminationGracePeriodSeconds: 0
  186. initContainers:
  187. - name: migrate
  188. image: {{ calico_upgrade_image }}
  189. command: ['/bin/sh', '-c', '/node-init-container.sh']
  190. env:
  191. # The location of the Calico etcd cluster.
  192. - name: CALICO_ETCD_ENDPOINTS
  193. valueFrom:
  194. configMapKeyRef:
  195. name: calico-config
  196. key: etcd_endpoints
  197. - name: CALICO_ETCD_CA_CERT_FILE
  198. valueFrom:
  199. configMapKeyRef:
  200. name: calico-config
  201. key: etcd_ca
  202. # Location of the client key for etcd.
  203. - name: CALICO_ETCD_KEY_FILE
  204. valueFrom:
  205. configMapKeyRef:
  206. name: calico-config
  207. key: etcd_key
  208. # Location of the client certificate for etcd.
  209. - name: CALICO_ETCD_CERT_FILE
  210. valueFrom:
  211. configMapKeyRef:
  212. name: calico-config
  213. key: etcd_cert
  214. # The location of the Calico etcd cluster.
  215. - name: CALICO_APIV1_ETCD_ENDPOINTS
  216. valueFrom:
  217. configMapKeyRef:
  218. name: calico-config
  219. key: etcd_endpoints
  220. - name: CALICO_APIV1_ETCD_CA_CERT_FILE
  221. valueFrom:
  222. configMapKeyRef:
  223. name: calico-config
  224. key: etcd_ca
  225. # Location of the client key for etcd.
  226. - name: CALICO_APIV1_ETCD_KEY_FILE
  227. valueFrom:
  228. configMapKeyRef:
  229. name: calico-config
  230. key: etcd_key
  231. # Location of the client certificate for etcd.
  232. - name: CALICO_APIV1_ETCD_CERT_FILE
  233. valueFrom:
  234. configMapKeyRef:
  235. name: calico-config
  236. key: etcd_cert
  237. - name: CALICO_APIV1_DATASTORE_TYPE
  238. value: "etcdv2"
  239. volumeMounts:
  240. - mountPath: /calico-secrets
  241. name: etcd-certs
  242. containers:
  243. # Runs calico/node container on each Kubernetes node. This
  244. # container programs network policy and routes on each
  245. # host.
  246. - name: calico-node
  247. image: {{ calico_node_image }}
  248. env:
  249. # The location of the Calico etcd cluster.
  250. - name: ETCD_ENDPOINTS
  251. valueFrom:
  252. configMapKeyRef:
  253. name: calico-config
  254. key: etcd_endpoints
  255. # Choose the backend to use.
  256. - name: CALICO_NETWORKING_BACKEND
  257. valueFrom:
  258. configMapKeyRef:
  259. name: calico-config
  260. key: calico_backend
  261. # Cluster type to identify the deployment type
  262. - name: CLUSTER_TYPE
  263. value: "origin,bgp"
  264. # Disable file logging so 'kubectl logs' works.
  265. - name: CALICO_DISABLE_FILE_LOGGING
  266. value: "true"
  267. # Set noderef for node controller.
  268. - name: CALICO_K8S_NODE_REF
  269. valueFrom:
  270. fieldRef:
  271. fieldPath: spec.nodeName
  272. # Set Felix endpoint to host default action to ACCEPT.
  273. - name: FELIX_DEFAULTENDPOINTTOHOSTACTION
  274. value: "ACCEPT"
  275. # The default IPv4 pool to create on startup if none exists. Pod IPs will be
  276. # chosen from this range. Changing this value after installation will have
  277. # no effect. This should fall within '--cluster-cidr'.
  278. - name: CALICO_IPV4POOL_CIDR
  279. value: "{{ openshift_cluster_network_cidr }}"
  280. - name: CALICO_IPV4POOL_IPIP
  281. value: "{{ calico_ipv4pool_ipip }}"
  282. # Disable IPv6 on Kubernetes.
  283. - name: FELIX_IPV6SUPPORT
  284. value: "false"
  285. # Set Felix logging to "info"
  286. - name: FELIX_LOGSEVERITYSCREEN
  287. value: "info"
  288. # Set MTU for tunnel device used if ipip is enabled
  289. - name: FELIX_IPINIPMTU
  290. value: "1440"
  291. - name: ETCD_ENDPOINTS
  292. valueFrom:
  293. configMapKeyRef:
  294. name: calico-config
  295. key: etcd_endpoints
  296. # Location of the CA certificate for etcd.
  297. - name: ETCD_CA_CERT_FILE
  298. valueFrom:
  299. configMapKeyRef:
  300. name: calico-config
  301. key: etcd_ca
  302. # Location of the client key for etcd.
  303. - name: ETCD_KEY_FILE
  304. valueFrom:
  305. configMapKeyRef:
  306. name: calico-config
  307. key: etcd_key
  308. # Location of the client certificate for etcd.
  309. - name: ETCD_CERT_FILE
  310. valueFrom:
  311. configMapKeyRef:
  312. name: calico-config
  313. key: etcd_cert
  314. # Auto-detect the BGP IP address.
  315. - name: IP
  316. value: "autodetect"
  317. - name: FELIX_HEALTHENABLED
  318. value: "true"
  319. securityContext:
  320. privileged: true
  321. resources:
  322. requests:
  323. cpu: 250m
  324. livenessProbe:
  325. httpGet:
  326. path: /liveness
  327. port: 9099
  328. {% if calico_binary_checks %}
  329. host: localhost
  330. {% endif %}
  331. periodSeconds: 10
  332. initialDelaySeconds: 10
  333. failureThreshold: 6
  334. readinessProbe:
  335. {% if calico_binary_checks %}
  336. exec:
  337. command:
  338. - /bin/calico-node
  339. - -bird-ready
  340. - -felix-ready
  341. {% else %}
  342. httpGet:
  343. path: /readiness
  344. port: 9099
  345. {% endif %}
  346. periodSeconds: 10
  347. volumeMounts:
  348. - mountPath: /lib/modules
  349. name: lib-modules
  350. readOnly: true
  351. - mountPath: /var/run/calico
  352. name: var-run-calico
  353. readOnly: false
  354. - mountPath: /var/lib/calico
  355. name: var-lib-calico
  356. readOnly: false
  357. - mountPath: /calico-secrets
  358. name: etcd-certs
  359. # This container installs the Calico CNI binaries
  360. # and CNI network config file on each node.
  361. - name: install-cni
  362. securityContext:
  363. privileged: true
  364. image: {{ calico_cni_image }}
  365. command: ["/install-cni.sh"]
  366. env:
  367. # Name of the CNI config file to create.
  368. - name: CNI_CONF_NAME
  369. value: "10-calico.conflist"
  370. # The location of the Calico etcd cluster.
  371. - name: ETCD_ENDPOINTS
  372. valueFrom:
  373. configMapKeyRef:
  374. name: calico-config
  375. key: etcd_endpoints
  376. # The CNI network config to install on each node.
  377. - name: CNI_NETWORK_CONFIG
  378. valueFrom:
  379. configMapKeyRef:
  380. name: calico-config
  381. key: cni_network_config
  382. # Location of the CA certificate for etcd.
  383. - name: CNI_CONF_ETCD_CA
  384. valueFrom:
  385. configMapKeyRef:
  386. name: calico-config
  387. key: etcd_ca
  388. # Location of the client key for etcd.
  389. - name: CNI_CONF_ETCD_KEY
  390. valueFrom:
  391. configMapKeyRef:
  392. name: calico-config
  393. key: etcd_key
  394. # Location of the client certificate for etcd.
  395. - name: CNI_CONF_ETCD_CERT
  396. valueFrom:
  397. configMapKeyRef:
  398. name: calico-config
  399. key: etcd_cert
  400. volumeMounts:
  401. - mountPath: /host/opt/cni/bin
  402. name: cni-bin-dir
  403. - mountPath: /host/etc/cni/net.d
  404. name: cni-net-dir
  405. - mountPath: /calico-secrets
  406. name: etcd-certs
  407. volumes:
  408. # Used by calico/node.
  409. - name: lib-modules
  410. hostPath:
  411. path: /lib/modules
  412. - name: var-run-calico
  413. hostPath:
  414. path: /var/run/calico
  415. - name: var-lib-calico
  416. hostPath:
  417. path: /var/lib/calico
  418. # Used to install CNI.
  419. - name: cni-bin-dir
  420. hostPath:
  421. path: {{ cni_bin_dir }}
  422. - name: cni-net-dir
  423. hostPath:
  424. path: {{ cni_conf_dir }}
  425. # Mount in the etcd TLS secrets with mode 400.
  426. # See https://kubernetes.io/docs/concepts/configuration/secret/
  427. - name: etcd-certs
  428. secret:
  429. secretName: calico-etcd-secrets
  430. defaultMode: 0400
  431. ---
  432. # This manifest deploys the Calico Kubernetes controllers.
  433. # See https://github.com/projectcalico/kube-controllers
  434. apiVersion: extensions/v1beta1
  435. kind: Deployment
  436. metadata:
  437. name: calico-kube-controllers
  438. namespace: kube-system
  439. labels:
  440. k8s-app: calico-kube-controllers
  441. annotations:
  442. scheduler.alpha.kubernetes.io/critical-pod: ''
  443. spec:
  444. # The controllers can only have a single active instance.
  445. replicas: 1
  446. strategy:
  447. type: Recreate
  448. template:
  449. metadata:
  450. name: calico-kube-controllers
  451. namespace: kube-system
  452. labels:
  453. k8s-app: calico-kube-controllers
  454. spec:
  455. {% if calico_image_credentials is defined %}
  456. imagePullSecrets:
  457. - name: calico-pull-secret
  458. {% endif %}
  459. # The controllers must run in the host network namespace so that
  460. # it isn't governed by policy that would prevent it from working.
  461. hostNetwork: true
  462. tolerations:
  463. # Mark the pod as a critical add-on for rescheduling.
  464. - key: CriticalAddonsOnly
  465. operator: Exists
  466. - key: node-role.kubernetes.io/master
  467. effect: NoSchedule
  468. serviceAccountName: calico-kube-controllers
  469. initContainers:
  470. - name: migrate
  471. image: {{ calico_upgrade_image }}
  472. command: ['/bin/sh', '-c', '/controller-init.sh']
  473. env:
  474. # The location of the Calico etcd cluster.
  475. - name: CALICO_ETCD_ENDPOINTS
  476. valueFrom:
  477. configMapKeyRef:
  478. name: calico-config
  479. key: etcd_endpoints
  480. - name: CALICO_ETCD_CA_CERT_FILE
  481. valueFrom:
  482. configMapKeyRef:
  483. name: calico-config
  484. key: etcd_ca
  485. # Location of the client key for etcd.
  486. - name: CALICO_ETCD_KEY_FILE
  487. valueFrom:
  488. configMapKeyRef:
  489. name: calico-config
  490. key: etcd_key
  491. # Location of the client certificate for etcd.
  492. - name: CALICO_ETCD_CERT_FILE
  493. valueFrom:
  494. configMapKeyRef:
  495. name: calico-config
  496. key: etcd_cert
  497. # The location of the Calico etcd cluster.
  498. - name: CALICO_APIV1_ETCD_ENDPOINTS
  499. valueFrom:
  500. configMapKeyRef:
  501. name: calico-config
  502. key: etcd_endpoints
  503. - name: CALICO_APIV1_ETCD_CA_CERT_FILE
  504. valueFrom:
  505. configMapKeyRef:
  506. name: calico-config
  507. key: etcd_ca
  508. # Location of the client key for etcd.
  509. - name: CALICO_APIV1_ETCD_KEY_FILE
  510. valueFrom:
  511. configMapKeyRef:
  512. name: calico-config
  513. key: etcd_key
  514. # Location of the client certificate for etcd.
  515. - name: CALICO_APIV1_ETCD_CERT_FILE
  516. valueFrom:
  517. configMapKeyRef:
  518. name: calico-config
  519. key: etcd_cert
  520. - name: CALICO_APIV1_DATASTORE_TYPE
  521. value: "etcdv2"
  522. volumeMounts:
  523. - mountPath: /calico-secrets
  524. name: etcd-certs
  525. containers:
  526. - name: calico-kube-controllers
  527. image: {{ calico_url_policy_controller }}
  528. securityContext:
  529. privileged: true
  530. env:
  531. # The location of the Calico etcd cluster.
  532. - name: ETCD_ENDPOINTS
  533. valueFrom:
  534. configMapKeyRef:
  535. name: calico-config
  536. key: etcd_endpoints
  537. # Location of the CA certificate for etcd.
  538. - name: ETCD_CA_CERT_FILE
  539. valueFrom:
  540. configMapKeyRef:
  541. name: calico-config
  542. key: etcd_ca
  543. # Location of the client key for etcd.
  544. - name: ETCD_KEY_FILE
  545. valueFrom:
  546. configMapKeyRef:
  547. name: calico-config
  548. key: etcd_key
  549. # Location of the client certificate for etcd.
  550. - name: ETCD_CERT_FILE
  551. valueFrom:
  552. configMapKeyRef:
  553. name: calico-config
  554. key: etcd_cert
  555. # Choose which controllers to run.
  556. - name: ENABLED_CONTROLLERS
  557. value: policy,profile,workloadendpoint,node
  558. volumeMounts:
  559. # Mount in the etcd TLS secrets.
  560. - mountPath: /calico-secrets
  561. name: etcd-certs
  562. volumes:
  563. # Mount in the etcd TLS secrets with mode 400.
  564. # See https://kubernetes.io/docs/concepts/configuration/secret/
  565. - name: etcd-certs
  566. secret:
  567. secretName: calico-etcd-secrets
  568. defaultMode: 0400
  569. ---
  570. apiVersion: batch/v1
  571. kind: Job
  572. metadata:
  573. name: complete-upgrade
  574. namespace: kube-system
  575. spec:
  576. template:
  577. spec:
  578. hostNetwork: true
  579. serviceAccountName: calico-upgrade-job
  580. restartPolicy: OnFailure
  581. containers:
  582. - name: migrate-completion
  583. image: {{ calico_upgrade_image }}
  584. command: ['/bin/sh', '-c', '/completion-job.sh']
  585. env:
  586. - name: EXPECTED_NODE_IMAGE
  587. valueFrom:
  588. configMapKeyRef:
  589. name: calico-config
  590. key: node_image
  591. # The location of the Calico etcd cluster.
  592. - name: CALICO_ETCD_ENDPOINTS
  593. valueFrom:
  594. configMapKeyRef:
  595. name: calico-config
  596. key: etcd_endpoints
  597. - name: CALICO_ETCD_CA_CERT_FILE
  598. valueFrom:
  599. configMapKeyRef:
  600. name: calico-config
  601. key: etcd_ca
  602. # Location of the client key for etcd.
  603. - name: CALICO_ETCD_KEY_FILE
  604. valueFrom:
  605. configMapKeyRef:
  606. name: calico-config
  607. key: etcd_key
  608. # Location of the client certificate for etcd.
  609. - name: CALICO_ETCD_CERT_FILE
  610. valueFrom:
  611. configMapKeyRef:
  612. name: calico-config
  613. key: etcd_cert
  614. # The location of the Calico etcd cluster.
  615. - name: CALICO_APIV1_ETCD_ENDPOINTS
  616. valueFrom:
  617. configMapKeyRef:
  618. name: calico-config
  619. key: etcd_endpoints
  620. - name: CALICO_APIV1_ETCD_CA_CERT_FILE
  621. valueFrom:
  622. configMapKeyRef:
  623. name: calico-config
  624. key: etcd_ca
  625. # Location of the client key for etcd.
  626. - name: CALICO_APIV1_ETCD_KEY_FILE
  627. valueFrom:
  628. configMapKeyRef:
  629. name: calico-config
  630. key: etcd_key
  631. # Location of the client certificate for etcd.
  632. - name: CALICO_APIV1_ETCD_CERT_FILE
  633. valueFrom:
  634. configMapKeyRef:
  635. name: calico-config
  636. key: etcd_cert
  637. - name: CALICO_APIV1_DATASTORE_TYPE
  638. value: "etcdv2"
  639. volumeMounts:
  640. - mountPath: /calico-secrets
  641. name: etcd-certs
  642. volumes:
  643. # Mount in the etcd TLS secrets with mode 400.
  644. # See https://kubernetes.io/docs/concepts/configuration/secret/
  645. - name: etcd-certs
  646. secret:
  647. secretName: calico-etcd-secrets
  648. defaultMode: 0400
  649. ---
  650. apiVersion: v1
  651. kind: ServiceAccount
  652. metadata:
  653. name: calico-upgrade-job
  654. namespace: kube-system
  655. ---
  656. apiVersion: v1
  657. kind: ServiceAccount
  658. metadata:
  659. name: calico-kube-controllers
  660. namespace: kube-system
  661. ---
  662. apiVersion: v1
  663. kind: ServiceAccount
  664. metadata:
  665. name: calico-node
  666. namespace: kube-system