calicov3.yml.j2 21 KB

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