calicov3.yml.j2 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  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. nodeSelector:
  173. projectcalico.org/ds-ready: "true"
  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.master.sdn_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. periodSeconds: 10
  331. initialDelaySeconds: 10
  332. failureThreshold: 6
  333. readinessProbe:
  334. httpGet:
  335. path: /readiness
  336. port: 9099
  337. periodSeconds: 10
  338. volumeMounts:
  339. - mountPath: /lib/modules
  340. name: lib-modules
  341. readOnly: true
  342. - mountPath: /var/run/calico
  343. name: var-run-calico
  344. readOnly: false
  345. - mountPath: /var/lib/calico
  346. name: var-lib-calico
  347. readOnly: false
  348. - mountPath: /calico-secrets
  349. name: etcd-certs
  350. # This container installs the Calico CNI binaries
  351. # and CNI network config file on each node.
  352. - name: install-cni
  353. securityContext:
  354. privileged: true
  355. image: {{ calico_cni_image }}
  356. command: ["/install-cni.sh"]
  357. env:
  358. # Name of the CNI config file to create.
  359. - name: CNI_CONF_NAME
  360. value: "10-calico.conflist"
  361. # The location of the Calico etcd cluster.
  362. - name: ETCD_ENDPOINTS
  363. valueFrom:
  364. configMapKeyRef:
  365. name: calico-config
  366. key: etcd_endpoints
  367. # The CNI network config to install on each node.
  368. - name: CNI_NETWORK_CONFIG
  369. valueFrom:
  370. configMapKeyRef:
  371. name: calico-config
  372. key: cni_network_config
  373. # Location of the CA certificate for etcd.
  374. - name: CNI_CONF_ETCD_CA
  375. valueFrom:
  376. configMapKeyRef:
  377. name: calico-config
  378. key: etcd_ca
  379. # Location of the client key for etcd.
  380. - name: CNI_CONF_ETCD_KEY
  381. valueFrom:
  382. configMapKeyRef:
  383. name: calico-config
  384. key: etcd_key
  385. # Location of the client certificate for etcd.
  386. - name: CNI_CONF_ETCD_CERT
  387. valueFrom:
  388. configMapKeyRef:
  389. name: calico-config
  390. key: etcd_cert
  391. volumeMounts:
  392. - mountPath: /host/opt/cni/bin
  393. name: cni-bin-dir
  394. - mountPath: /host/etc/cni/net.d
  395. name: cni-net-dir
  396. - mountPath: /calico-secrets
  397. name: etcd-certs
  398. volumes:
  399. # Used by calico/node.
  400. - name: lib-modules
  401. hostPath:
  402. path: /lib/modules
  403. - name: var-run-calico
  404. hostPath:
  405. path: /var/run/calico
  406. - name: var-lib-calico
  407. hostPath:
  408. path: /var/lib/calico
  409. # Used to install CNI.
  410. - name: cni-bin-dir
  411. hostPath:
  412. path: {{ cni_bin_dir }}
  413. - name: cni-net-dir
  414. hostPath:
  415. path: {{ cni_conf_dir }}
  416. # Mount in the etcd TLS secrets with mode 400.
  417. # See https://kubernetes.io/docs/concepts/configuration/secret/
  418. - name: etcd-certs
  419. secret:
  420. secretName: calico-etcd-secrets
  421. defaultMode: 0400
  422. ---
  423. # This manifest deploys the Calico Kubernetes controllers.
  424. # See https://github.com/projectcalico/kube-controllers
  425. apiVersion: extensions/v1beta1
  426. kind: Deployment
  427. metadata:
  428. name: calico-kube-controllers
  429. namespace: kube-system
  430. labels:
  431. k8s-app: calico-kube-controllers
  432. annotations:
  433. scheduler.alpha.kubernetes.io/critical-pod: ''
  434. spec:
  435. # The controllers can only have a single active instance.
  436. replicas: 1
  437. strategy:
  438. type: Recreate
  439. template:
  440. metadata:
  441. name: calico-kube-controllers
  442. namespace: kube-system
  443. labels:
  444. k8s-app: calico-kube-controllers
  445. spec:
  446. # The controllers must run in the host network namespace so that
  447. # it isn't governed by policy that would prevent it from working.
  448. hostNetwork: true
  449. tolerations:
  450. # Mark the pod as a critical add-on for rescheduling.
  451. - key: CriticalAddonsOnly
  452. operator: Exists
  453. - key: node-role.kubernetes.io/master
  454. effect: NoSchedule
  455. serviceAccountName: calico-kube-controllers
  456. initContainers:
  457. - name: migrate
  458. image: {{ calico_upgrade_image }}
  459. command: ['/bin/sh', '-c', '/controller-init.sh']
  460. env:
  461. # The location of the Calico etcd cluster.
  462. - name: CALICO_ETCD_ENDPOINTS
  463. valueFrom:
  464. configMapKeyRef:
  465. name: calico-config
  466. key: etcd_endpoints
  467. - name: CALICO_ETCD_CA_CERT_FILE
  468. valueFrom:
  469. configMapKeyRef:
  470. name: calico-config
  471. key: etcd_ca
  472. # Location of the client key for etcd.
  473. - name: CALICO_ETCD_KEY_FILE
  474. valueFrom:
  475. configMapKeyRef:
  476. name: calico-config
  477. key: etcd_key
  478. # Location of the client certificate for etcd.
  479. - name: CALICO_ETCD_CERT_FILE
  480. valueFrom:
  481. configMapKeyRef:
  482. name: calico-config
  483. key: etcd_cert
  484. # The location of the Calico etcd cluster.
  485. - name: CALICO_APIV1_ETCD_ENDPOINTS
  486. valueFrom:
  487. configMapKeyRef:
  488. name: calico-config
  489. key: etcd_endpoints
  490. - name: CALICO_APIV1_ETCD_CA_CERT_FILE
  491. valueFrom:
  492. configMapKeyRef:
  493. name: calico-config
  494. key: etcd_ca
  495. # Location of the client key for etcd.
  496. - name: CALICO_APIV1_ETCD_KEY_FILE
  497. valueFrom:
  498. configMapKeyRef:
  499. name: calico-config
  500. key: etcd_key
  501. # Location of the client certificate for etcd.
  502. - name: CALICO_APIV1_ETCD_CERT_FILE
  503. valueFrom:
  504. configMapKeyRef:
  505. name: calico-config
  506. key: etcd_cert
  507. - name: CALICO_APIV1_DATASTORE_TYPE
  508. value: "etcdv2"
  509. volumeMounts:
  510. - mountPath: /calico-secrets
  511. name: etcd-certs
  512. containers:
  513. - name: calico-kube-controllers
  514. image: {{ calico_url_policy_controller }}
  515. securityContext:
  516. privileged: true
  517. env:
  518. # The location of the Calico etcd cluster.
  519. - name: ETCD_ENDPOINTS
  520. valueFrom:
  521. configMapKeyRef:
  522. name: calico-config
  523. key: etcd_endpoints
  524. # Location of the CA certificate for etcd.
  525. - name: ETCD_CA_CERT_FILE
  526. valueFrom:
  527. configMapKeyRef:
  528. name: calico-config
  529. key: etcd_ca
  530. # Location of the client key for etcd.
  531. - name: ETCD_KEY_FILE
  532. valueFrom:
  533. configMapKeyRef:
  534. name: calico-config
  535. key: etcd_key
  536. # Location of the client certificate for etcd.
  537. - name: ETCD_CERT_FILE
  538. valueFrom:
  539. configMapKeyRef:
  540. name: calico-config
  541. key: etcd_cert
  542. # Choose which controllers to run.
  543. - name: ENABLED_CONTROLLERS
  544. value: policy,profile,workloadendpoint,node
  545. volumeMounts:
  546. # Mount in the etcd TLS secrets.
  547. - mountPath: /calico-secrets
  548. name: etcd-certs
  549. volumes:
  550. # Mount in the etcd TLS secrets with mode 400.
  551. # See https://kubernetes.io/docs/concepts/configuration/secret/
  552. - name: etcd-certs
  553. secret:
  554. secretName: calico-etcd-secrets
  555. defaultMode: 0400
  556. ---
  557. apiVersion: batch/v1
  558. kind: Job
  559. metadata:
  560. name: complete-upgrade
  561. namespace: kube-system
  562. spec:
  563. template:
  564. spec:
  565. hostNetwork: true
  566. serviceAccountName: calico-upgrade-job
  567. restartPolicy: OnFailure
  568. containers:
  569. - name: migrate-completion
  570. image: {{ calico_upgrade_image }}
  571. command: ['/bin/sh', '-c', '/completion-job.sh']
  572. env:
  573. - name: EXPECTED_NODE_IMAGE
  574. valueFrom:
  575. configMapKeyRef:
  576. name: calico-config
  577. key: node_image
  578. # The location of the Calico etcd cluster.
  579. - name: CALICO_ETCD_ENDPOINTS
  580. valueFrom:
  581. configMapKeyRef:
  582. name: calico-config
  583. key: etcd_endpoints
  584. - name: CALICO_ETCD_CA_CERT_FILE
  585. valueFrom:
  586. configMapKeyRef:
  587. name: calico-config
  588. key: etcd_ca
  589. # Location of the client key for etcd.
  590. - name: CALICO_ETCD_KEY_FILE
  591. valueFrom:
  592. configMapKeyRef:
  593. name: calico-config
  594. key: etcd_key
  595. # Location of the client certificate for etcd.
  596. - name: CALICO_ETCD_CERT_FILE
  597. valueFrom:
  598. configMapKeyRef:
  599. name: calico-config
  600. key: etcd_cert
  601. # The location of the Calico etcd cluster.
  602. - name: CALICO_APIV1_ETCD_ENDPOINTS
  603. valueFrom:
  604. configMapKeyRef:
  605. name: calico-config
  606. key: etcd_endpoints
  607. - name: CALICO_APIV1_ETCD_CA_CERT_FILE
  608. valueFrom:
  609. configMapKeyRef:
  610. name: calico-config
  611. key: etcd_ca
  612. # Location of the client key for etcd.
  613. - name: CALICO_APIV1_ETCD_KEY_FILE
  614. valueFrom:
  615. configMapKeyRef:
  616. name: calico-config
  617. key: etcd_key
  618. # Location of the client certificate for etcd.
  619. - name: CALICO_APIV1_ETCD_CERT_FILE
  620. valueFrom:
  621. configMapKeyRef:
  622. name: calico-config
  623. key: etcd_cert
  624. - name: CALICO_APIV1_DATASTORE_TYPE
  625. value: "etcdv2"
  626. volumeMounts:
  627. - mountPath: /calico-secrets
  628. name: etcd-certs
  629. volumes:
  630. # Mount in the etcd TLS secrets with mode 400.
  631. # See https://kubernetes.io/docs/concepts/configuration/secret/
  632. - name: etcd-certs
  633. secret:
  634. secretName: calico-etcd-secrets
  635. defaultMode: 0400
  636. ---
  637. apiVersion: v1
  638. kind: ServiceAccount
  639. metadata:
  640. name: calico-upgrade-job
  641. namespace: kube-system
  642. ---
  643. apiVersion: v1
  644. kind: ServiceAccount
  645. metadata:
  646. name: calico-kube-controllers
  647. namespace: kube-system
  648. ---
  649. apiVersion: v1
  650. kind: ServiceAccount
  651. metadata:
  652. name: calico-node
  653. namespace: kube-system