calicov3.yml.j2 20 KB

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