calicov3.yml.j2 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  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. # The controllers must run in the host network namespace so that
  458. # it isn't governed by policy that would prevent it from working.
  459. hostNetwork: true
  460. tolerations:
  461. # Mark the pod as a critical add-on for rescheduling.
  462. - key: CriticalAddonsOnly
  463. operator: Exists
  464. - key: node-role.kubernetes.io/master
  465. effect: NoSchedule
  466. serviceAccountName: calico-kube-controllers
  467. initContainers:
  468. - name: migrate
  469. image: {{ calico_upgrade_image }}
  470. command: ['/bin/sh', '-c', '/controller-init.sh']
  471. env:
  472. # The location of the Calico etcd cluster.
  473. - name: CALICO_ETCD_ENDPOINTS
  474. valueFrom:
  475. configMapKeyRef:
  476. name: calico-config
  477. key: etcd_endpoints
  478. - name: CALICO_ETCD_CA_CERT_FILE
  479. valueFrom:
  480. configMapKeyRef:
  481. name: calico-config
  482. key: etcd_ca
  483. # Location of the client key for etcd.
  484. - name: CALICO_ETCD_KEY_FILE
  485. valueFrom:
  486. configMapKeyRef:
  487. name: calico-config
  488. key: etcd_key
  489. # Location of the client certificate for etcd.
  490. - name: CALICO_ETCD_CERT_FILE
  491. valueFrom:
  492. configMapKeyRef:
  493. name: calico-config
  494. key: etcd_cert
  495. # The location of the Calico etcd cluster.
  496. - name: CALICO_APIV1_ETCD_ENDPOINTS
  497. valueFrom:
  498. configMapKeyRef:
  499. name: calico-config
  500. key: etcd_endpoints
  501. - name: CALICO_APIV1_ETCD_CA_CERT_FILE
  502. valueFrom:
  503. configMapKeyRef:
  504. name: calico-config
  505. key: etcd_ca
  506. # Location of the client key for etcd.
  507. - name: CALICO_APIV1_ETCD_KEY_FILE
  508. valueFrom:
  509. configMapKeyRef:
  510. name: calico-config
  511. key: etcd_key
  512. # Location of the client certificate for etcd.
  513. - name: CALICO_APIV1_ETCD_CERT_FILE
  514. valueFrom:
  515. configMapKeyRef:
  516. name: calico-config
  517. key: etcd_cert
  518. - name: CALICO_APIV1_DATASTORE_TYPE
  519. value: "etcdv2"
  520. volumeMounts:
  521. - mountPath: /calico-secrets
  522. name: etcd-certs
  523. containers:
  524. - name: calico-kube-controllers
  525. image: {{ calico_url_policy_controller }}
  526. securityContext:
  527. privileged: true
  528. env:
  529. # The location of the Calico etcd cluster.
  530. - name: ETCD_ENDPOINTS
  531. valueFrom:
  532. configMapKeyRef:
  533. name: calico-config
  534. key: etcd_endpoints
  535. # Location of the CA certificate for etcd.
  536. - name: ETCD_CA_CERT_FILE
  537. valueFrom:
  538. configMapKeyRef:
  539. name: calico-config
  540. key: etcd_ca
  541. # Location of the client key for etcd.
  542. - name: ETCD_KEY_FILE
  543. valueFrom:
  544. configMapKeyRef:
  545. name: calico-config
  546. key: etcd_key
  547. # Location of the client certificate for etcd.
  548. - name: ETCD_CERT_FILE
  549. valueFrom:
  550. configMapKeyRef:
  551. name: calico-config
  552. key: etcd_cert
  553. # Choose which controllers to run.
  554. - name: ENABLED_CONTROLLERS
  555. value: policy,profile,workloadendpoint,node
  556. volumeMounts:
  557. # Mount in the etcd TLS secrets.
  558. - mountPath: /calico-secrets
  559. name: etcd-certs
  560. volumes:
  561. # Mount in the etcd TLS secrets with mode 400.
  562. # See https://kubernetes.io/docs/concepts/configuration/secret/
  563. - name: etcd-certs
  564. secret:
  565. secretName: calico-etcd-secrets
  566. defaultMode: 0400
  567. ---
  568. apiVersion: batch/v1
  569. kind: Job
  570. metadata:
  571. name: complete-upgrade
  572. namespace: kube-system
  573. spec:
  574. template:
  575. spec:
  576. hostNetwork: true
  577. serviceAccountName: calico-upgrade-job
  578. restartPolicy: OnFailure
  579. containers:
  580. - name: migrate-completion
  581. image: {{ calico_upgrade_image }}
  582. command: ['/bin/sh', '-c', '/completion-job.sh']
  583. env:
  584. - name: EXPECTED_NODE_IMAGE
  585. valueFrom:
  586. configMapKeyRef:
  587. name: calico-config
  588. key: node_image
  589. # The location of the Calico etcd cluster.
  590. - name: CALICO_ETCD_ENDPOINTS
  591. valueFrom:
  592. configMapKeyRef:
  593. name: calico-config
  594. key: etcd_endpoints
  595. - name: CALICO_ETCD_CA_CERT_FILE
  596. valueFrom:
  597. configMapKeyRef:
  598. name: calico-config
  599. key: etcd_ca
  600. # Location of the client key for etcd.
  601. - name: CALICO_ETCD_KEY_FILE
  602. valueFrom:
  603. configMapKeyRef:
  604. name: calico-config
  605. key: etcd_key
  606. # Location of the client certificate for etcd.
  607. - name: CALICO_ETCD_CERT_FILE
  608. valueFrom:
  609. configMapKeyRef:
  610. name: calico-config
  611. key: etcd_cert
  612. # The location of the Calico etcd cluster.
  613. - name: CALICO_APIV1_ETCD_ENDPOINTS
  614. valueFrom:
  615. configMapKeyRef:
  616. name: calico-config
  617. key: etcd_endpoints
  618. - name: CALICO_APIV1_ETCD_CA_CERT_FILE
  619. valueFrom:
  620. configMapKeyRef:
  621. name: calico-config
  622. key: etcd_ca
  623. # Location of the client key for etcd.
  624. - name: CALICO_APIV1_ETCD_KEY_FILE
  625. valueFrom:
  626. configMapKeyRef:
  627. name: calico-config
  628. key: etcd_key
  629. # Location of the client certificate for etcd.
  630. - name: CALICO_APIV1_ETCD_CERT_FILE
  631. valueFrom:
  632. configMapKeyRef:
  633. name: calico-config
  634. key: etcd_cert
  635. - name: CALICO_APIV1_DATASTORE_TYPE
  636. value: "etcdv2"
  637. volumeMounts:
  638. - mountPath: /calico-secrets
  639. name: etcd-certs
  640. volumes:
  641. # Mount in the etcd TLS secrets with mode 400.
  642. # See https://kubernetes.io/docs/concepts/configuration/secret/
  643. - name: etcd-certs
  644. secret:
  645. secretName: calico-etcd-secrets
  646. defaultMode: 0400
  647. ---
  648. apiVersion: v1
  649. kind: ServiceAccount
  650. metadata:
  651. name: calico-upgrade-job
  652. namespace: kube-system
  653. ---
  654. apiVersion: v1
  655. kind: ServiceAccount
  656. metadata:
  657. name: calico-kube-controllers
  658. namespace: kube-system
  659. ---
  660. apiVersion: v1
  661. kind: ServiceAccount
  662. metadata:
  663. name: calico-node
  664. namespace: kube-system