calicov3.yml.j2 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  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. nodeSelector:
  169. projectcalico.org/ds-ready: "true"
  170. hostNetwork: true
  171. tolerations:
  172. # Make sure calico/node gets scheduled on all nodes.
  173. - effect: NoSchedule
  174. operator: Exists
  175. # Mark the pod as a critical add-on for rescheduling.
  176. - key: CriticalAddonsOnly
  177. operator: Exists
  178. - effect: NoExecute
  179. operator: Exists
  180. serviceAccountName: calico-node
  181. # Minimize downtime during a rolling upgrade or deletion; tell Kubernetes to do a "force
  182. # deletion": https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods.
  183. terminationGracePeriodSeconds: 0
  184. initContainers:
  185. - name: migrate
  186. image: {{ calico_upgrade_image }}
  187. command: ['/bin/sh', '-c', '/node-init-container.sh']
  188. env:
  189. # The location of the Calico etcd cluster.
  190. - name: CALICO_ETCD_ENDPOINTS
  191. valueFrom:
  192. configMapKeyRef:
  193. name: calico-config
  194. key: etcd_endpoints
  195. - name: CALICO_ETCD_CA_CERT_FILE
  196. valueFrom:
  197. configMapKeyRef:
  198. name: calico-config
  199. key: etcd_ca
  200. # Location of the client key for etcd.
  201. - name: CALICO_ETCD_KEY_FILE
  202. valueFrom:
  203. configMapKeyRef:
  204. name: calico-config
  205. key: etcd_key
  206. # Location of the client certificate for etcd.
  207. - name: CALICO_ETCD_CERT_FILE
  208. valueFrom:
  209. configMapKeyRef:
  210. name: calico-config
  211. key: etcd_cert
  212. # The location of the Calico etcd cluster.
  213. - name: CALICO_APIV1_ETCD_ENDPOINTS
  214. valueFrom:
  215. configMapKeyRef:
  216. name: calico-config
  217. key: etcd_endpoints
  218. - name: CALICO_APIV1_ETCD_CA_CERT_FILE
  219. valueFrom:
  220. configMapKeyRef:
  221. name: calico-config
  222. key: etcd_ca
  223. # Location of the client key for etcd.
  224. - name: CALICO_APIV1_ETCD_KEY_FILE
  225. valueFrom:
  226. configMapKeyRef:
  227. name: calico-config
  228. key: etcd_key
  229. # Location of the client certificate for etcd.
  230. - name: CALICO_APIV1_ETCD_CERT_FILE
  231. valueFrom:
  232. configMapKeyRef:
  233. name: calico-config
  234. key: etcd_cert
  235. - name: CALICO_APIV1_DATASTORE_TYPE
  236. value: "etcdv2"
  237. volumeMounts:
  238. - mountPath: /calico-secrets
  239. name: etcd-certs
  240. containers:
  241. # Runs calico/node container on each Kubernetes node. This
  242. # container programs network policy and routes on each
  243. # host.
  244. - name: calico-node
  245. image: {{ calico_node_image }}
  246. env:
  247. # The location of the Calico etcd cluster.
  248. - name: ETCD_ENDPOINTS
  249. valueFrom:
  250. configMapKeyRef:
  251. name: calico-config
  252. key: etcd_endpoints
  253. # Choose the backend to use.
  254. - name: CALICO_NETWORKING_BACKEND
  255. valueFrom:
  256. configMapKeyRef:
  257. name: calico-config
  258. key: calico_backend
  259. # Cluster type to identify the deployment type
  260. - name: CLUSTER_TYPE
  261. value: "origin,bgp"
  262. # Disable file logging so 'kubectl logs' works.
  263. - name: CALICO_DISABLE_FILE_LOGGING
  264. value: "true"
  265. # Set noderef for node controller.
  266. - name: CALICO_K8S_NODE_REF
  267. valueFrom:
  268. fieldRef:
  269. fieldPath: spec.nodeName
  270. # Set Felix endpoint to host default action to ACCEPT.
  271. - name: FELIX_DEFAULTENDPOINTTOHOSTACTION
  272. value: "ACCEPT"
  273. # The default IPv4 pool to create on startup if none exists. Pod IPs will be
  274. # chosen from this range. Changing this value after installation will have
  275. # no effect. This should fall within '--cluster-cidr'.
  276. - name: CALICO_IPV4POOL_CIDR
  277. value: "{{ openshift.master.sdn_cluster_network_cidr }}"
  278. - name: CALICO_IPV4POOL_IPIP
  279. value: "{{ calico_ipv4pool_ipip }}"
  280. # Disable IPv6 on Kubernetes.
  281. - name: FELIX_IPV6SUPPORT
  282. value: "false"
  283. # Set Felix logging to "info"
  284. - name: FELIX_LOGSEVERITYSCREEN
  285. value: "info"
  286. # Set MTU for tunnel device used if ipip is enabled
  287. - name: FELIX_IPINIPMTU
  288. value: "1440"
  289. - name: ETCD_ENDPOINTS
  290. valueFrom:
  291. configMapKeyRef:
  292. name: calico-config
  293. key: etcd_endpoints
  294. # Location of the CA certificate for etcd.
  295. - name: ETCD_CA_CERT_FILE
  296. valueFrom:
  297. configMapKeyRef:
  298. name: calico-config
  299. key: etcd_ca
  300. # Location of the client key for etcd.
  301. - name: ETCD_KEY_FILE
  302. valueFrom:
  303. configMapKeyRef:
  304. name: calico-config
  305. key: etcd_key
  306. # Location of the client certificate for etcd.
  307. - name: ETCD_CERT_FILE
  308. valueFrom:
  309. configMapKeyRef:
  310. name: calico-config
  311. key: etcd_cert
  312. # Auto-detect the BGP IP address.
  313. - name: IP
  314. value: "autodetect"
  315. - name: FELIX_HEALTHENABLED
  316. value: "true"
  317. securityContext:
  318. privileged: true
  319. resources:
  320. requests:
  321. cpu: 250m
  322. livenessProbe:
  323. httpGet:
  324. path: /liveness
  325. port: 9099
  326. {% if calico_binary_checks %}
  327. host: localhost
  328. {% endif %}
  329. periodSeconds: 10
  330. initialDelaySeconds: 10
  331. failureThreshold: 6
  332. readinessProbe:
  333. {% if calico_binary_checks %}
  334. exec:
  335. command:
  336. - /bin/calico-node
  337. - -bird-ready
  338. - -felix-ready
  339. {% else %}
  340. httpGet:
  341. path: /readiness
  342. port: 9099
  343. {% endif %}
  344. periodSeconds: 10
  345. volumeMounts:
  346. - mountPath: /lib/modules
  347. name: lib-modules
  348. readOnly: true
  349. - mountPath: /var/run/calico
  350. name: var-run-calico
  351. readOnly: false
  352. - mountPath: /var/lib/calico
  353. name: var-lib-calico
  354. readOnly: false
  355. - mountPath: /calico-secrets
  356. name: etcd-certs
  357. # This container installs the Calico CNI binaries
  358. # and CNI network config file on each node.
  359. - name: install-cni
  360. securityContext:
  361. privileged: true
  362. image: {{ calico_cni_image }}
  363. command: ["/install-cni.sh"]
  364. env:
  365. # Name of the CNI config file to create.
  366. - name: CNI_CONF_NAME
  367. value: "10-calico.conflist"
  368. # The location of the Calico etcd cluster.
  369. - name: ETCD_ENDPOINTS
  370. valueFrom:
  371. configMapKeyRef:
  372. name: calico-config
  373. key: etcd_endpoints
  374. # The CNI network config to install on each node.
  375. - name: CNI_NETWORK_CONFIG
  376. valueFrom:
  377. configMapKeyRef:
  378. name: calico-config
  379. key: cni_network_config
  380. # Location of the CA certificate for etcd.
  381. - name: CNI_CONF_ETCD_CA
  382. valueFrom:
  383. configMapKeyRef:
  384. name: calico-config
  385. key: etcd_ca
  386. # Location of the client key for etcd.
  387. - name: CNI_CONF_ETCD_KEY
  388. valueFrom:
  389. configMapKeyRef:
  390. name: calico-config
  391. key: etcd_key
  392. # Location of the client certificate for etcd.
  393. - name: CNI_CONF_ETCD_CERT
  394. valueFrom:
  395. configMapKeyRef:
  396. name: calico-config
  397. key: etcd_cert
  398. volumeMounts:
  399. - mountPath: /host/opt/cni/bin
  400. name: cni-bin-dir
  401. - mountPath: /host/etc/cni/net.d
  402. name: cni-net-dir
  403. - mountPath: /calico-secrets
  404. name: etcd-certs
  405. volumes:
  406. # Used by calico/node.
  407. - name: lib-modules
  408. hostPath:
  409. path: /lib/modules
  410. - name: var-run-calico
  411. hostPath:
  412. path: /var/run/calico
  413. - name: var-lib-calico
  414. hostPath:
  415. path: /var/lib/calico
  416. # Used to install CNI.
  417. - name: cni-bin-dir
  418. hostPath:
  419. path: {{ cni_bin_dir }}
  420. - name: cni-net-dir
  421. hostPath:
  422. path: {{ cni_conf_dir }}
  423. # Mount in the etcd TLS secrets with mode 400.
  424. # See https://kubernetes.io/docs/concepts/configuration/secret/
  425. - name: etcd-certs
  426. secret:
  427. secretName: calico-etcd-secrets
  428. defaultMode: 0400
  429. ---
  430. # This manifest deploys the Calico Kubernetes controllers.
  431. # See https://github.com/projectcalico/kube-controllers
  432. apiVersion: extensions/v1beta1
  433. kind: Deployment
  434. metadata:
  435. name: calico-kube-controllers
  436. namespace: kube-system
  437. labels:
  438. k8s-app: calico-kube-controllers
  439. annotations:
  440. scheduler.alpha.kubernetes.io/critical-pod: ''
  441. spec:
  442. # The controllers can only have a single active instance.
  443. replicas: 1
  444. strategy:
  445. type: Recreate
  446. template:
  447. metadata:
  448. name: calico-kube-controllers
  449. namespace: kube-system
  450. labels:
  451. k8s-app: calico-kube-controllers
  452. spec:
  453. # The controllers must run in the host network namespace so that
  454. # it isn't governed by policy that would prevent it from working.
  455. hostNetwork: true
  456. tolerations:
  457. # Mark the pod as a critical add-on for rescheduling.
  458. - key: CriticalAddonsOnly
  459. operator: Exists
  460. - key: node-role.kubernetes.io/master
  461. effect: NoSchedule
  462. serviceAccountName: calico-kube-controllers
  463. initContainers:
  464. - name: migrate
  465. image: {{ calico_upgrade_image }}
  466. command: ['/bin/sh', '-c', '/controller-init.sh']
  467. env:
  468. # The location of the Calico etcd cluster.
  469. - name: CALICO_ETCD_ENDPOINTS
  470. valueFrom:
  471. configMapKeyRef:
  472. name: calico-config
  473. key: etcd_endpoints
  474. - name: CALICO_ETCD_CA_CERT_FILE
  475. valueFrom:
  476. configMapKeyRef:
  477. name: calico-config
  478. key: etcd_ca
  479. # Location of the client key for etcd.
  480. - name: CALICO_ETCD_KEY_FILE
  481. valueFrom:
  482. configMapKeyRef:
  483. name: calico-config
  484. key: etcd_key
  485. # Location of the client certificate for etcd.
  486. - name: CALICO_ETCD_CERT_FILE
  487. valueFrom:
  488. configMapKeyRef:
  489. name: calico-config
  490. key: etcd_cert
  491. # The location of the Calico etcd cluster.
  492. - name: CALICO_APIV1_ETCD_ENDPOINTS
  493. valueFrom:
  494. configMapKeyRef:
  495. name: calico-config
  496. key: etcd_endpoints
  497. - name: CALICO_APIV1_ETCD_CA_CERT_FILE
  498. valueFrom:
  499. configMapKeyRef:
  500. name: calico-config
  501. key: etcd_ca
  502. # Location of the client key for etcd.
  503. - name: CALICO_APIV1_ETCD_KEY_FILE
  504. valueFrom:
  505. configMapKeyRef:
  506. name: calico-config
  507. key: etcd_key
  508. # Location of the client certificate for etcd.
  509. - name: CALICO_APIV1_ETCD_CERT_FILE
  510. valueFrom:
  511. configMapKeyRef:
  512. name: calico-config
  513. key: etcd_cert
  514. - name: CALICO_APIV1_DATASTORE_TYPE
  515. value: "etcdv2"
  516. volumeMounts:
  517. - mountPath: /calico-secrets
  518. name: etcd-certs
  519. containers:
  520. - name: calico-kube-controllers
  521. image: {{ calico_url_policy_controller }}
  522. securityContext:
  523. privileged: true
  524. env:
  525. # The location of the Calico etcd cluster.
  526. - name: ETCD_ENDPOINTS
  527. valueFrom:
  528. configMapKeyRef:
  529. name: calico-config
  530. key: etcd_endpoints
  531. # Location of the CA certificate for etcd.
  532. - name: ETCD_CA_CERT_FILE
  533. valueFrom:
  534. configMapKeyRef:
  535. name: calico-config
  536. key: etcd_ca
  537. # Location of the client key for etcd.
  538. - name: ETCD_KEY_FILE
  539. valueFrom:
  540. configMapKeyRef:
  541. name: calico-config
  542. key: etcd_key
  543. # Location of the client certificate for etcd.
  544. - name: ETCD_CERT_FILE
  545. valueFrom:
  546. configMapKeyRef:
  547. name: calico-config
  548. key: etcd_cert
  549. # Choose which controllers to run.
  550. - name: ENABLED_CONTROLLERS
  551. value: policy,profile,workloadendpoint,node
  552. volumeMounts:
  553. # Mount in the etcd TLS secrets.
  554. - mountPath: /calico-secrets
  555. name: etcd-certs
  556. volumes:
  557. # Mount in the etcd TLS secrets with mode 400.
  558. # See https://kubernetes.io/docs/concepts/configuration/secret/
  559. - name: etcd-certs
  560. secret:
  561. secretName: calico-etcd-secrets
  562. defaultMode: 0400
  563. ---
  564. apiVersion: batch/v1
  565. kind: Job
  566. metadata:
  567. name: complete-upgrade
  568. namespace: kube-system
  569. spec:
  570. template:
  571. spec:
  572. hostNetwork: true
  573. serviceAccountName: calico-upgrade-job
  574. restartPolicy: OnFailure
  575. containers:
  576. - name: migrate-completion
  577. image: {{ calico_upgrade_image }}
  578. command: ['/bin/sh', '-c', '/completion-job.sh']
  579. env:
  580. - name: EXPECTED_NODE_IMAGE
  581. valueFrom:
  582. configMapKeyRef:
  583. name: calico-config
  584. key: node_image
  585. # The location of the Calico etcd cluster.
  586. - name: CALICO_ETCD_ENDPOINTS
  587. valueFrom:
  588. configMapKeyRef:
  589. name: calico-config
  590. key: etcd_endpoints
  591. - name: CALICO_ETCD_CA_CERT_FILE
  592. valueFrom:
  593. configMapKeyRef:
  594. name: calico-config
  595. key: etcd_ca
  596. # Location of the client key for etcd.
  597. - name: CALICO_ETCD_KEY_FILE
  598. valueFrom:
  599. configMapKeyRef:
  600. name: calico-config
  601. key: etcd_key
  602. # Location of the client certificate for etcd.
  603. - name: CALICO_ETCD_CERT_FILE
  604. valueFrom:
  605. configMapKeyRef:
  606. name: calico-config
  607. key: etcd_cert
  608. # The location of the Calico etcd cluster.
  609. - name: CALICO_APIV1_ETCD_ENDPOINTS
  610. valueFrom:
  611. configMapKeyRef:
  612. name: calico-config
  613. key: etcd_endpoints
  614. - name: CALICO_APIV1_ETCD_CA_CERT_FILE
  615. valueFrom:
  616. configMapKeyRef:
  617. name: calico-config
  618. key: etcd_ca
  619. # Location of the client key for etcd.
  620. - name: CALICO_APIV1_ETCD_KEY_FILE
  621. valueFrom:
  622. configMapKeyRef:
  623. name: calico-config
  624. key: etcd_key
  625. # Location of the client certificate for etcd.
  626. - name: CALICO_APIV1_ETCD_CERT_FILE
  627. valueFrom:
  628. configMapKeyRef:
  629. name: calico-config
  630. key: etcd_cert
  631. - name: CALICO_APIV1_DATASTORE_TYPE
  632. value: "etcdv2"
  633. volumeMounts:
  634. - mountPath: /calico-secrets
  635. name: etcd-certs
  636. volumes:
  637. # Mount in the etcd TLS secrets with mode 400.
  638. # See https://kubernetes.io/docs/concepts/configuration/secret/
  639. - name: etcd-certs
  640. secret:
  641. secretName: calico-etcd-secrets
  642. defaultMode: 0400
  643. ---
  644. apiVersion: v1
  645. kind: ServiceAccount
  646. metadata:
  647. name: calico-upgrade-job
  648. namespace: kube-system
  649. ---
  650. apiVersion: v1
  651. kind: ServiceAccount
  652. metadata:
  653. name: calico-kube-controllers
  654. namespace: kube-system
  655. ---
  656. apiVersion: v1
  657. kind: ServiceAccount
  658. metadata:
  659. name: calico-node
  660. namespace: kube-system