CSIT-870 Kubernetes/Ligato integration
[csit.git] / resources / templates / kubernetes / calico_v2.6.3.yaml
1 # Calico Version v2.6.3
2 # https://docs.projectcalico.org/v2.6/releases#v2.6.3
3 # This manifest includes the following component versions:
4 #   calico/node:v2.6.3
5 #   calico/cni:v1.11.1
6 #   calico/kube-controllers:v1.0.1
7
8 # This ConfigMap is used to configure a self-hosted Calico installation.
9 kind: ConfigMap
10 apiVersion: v1
11 metadata:
12   name: calico-config
13   namespace: kube-system
14 data:
15   # The location of your etcd cluster.  This uses the Service clusterIP
16   # defined below.
17   etcd_endpoints: "http://10.96.232.136:6666"
18
19   # Configure the Calico backend to use.
20   calico_backend: "bird"
21
22   # The CNI network configuration to install on each node.
23   cni_network_config: |-
24     {
25         "name": "k8s-pod-network",
26         "cniVersion": "0.1.0",
27         "type": "calico",
28         "etcd_endpoints": "__ETCD_ENDPOINTS__",
29         "log_level": "info",
30         "mtu": 1500,
31         "ipam": {
32             "type": "calico-ipam"
33         },
34         "policy": {
35             "type": "k8s",
36              "k8s_api_root": "https://__KUBERNETES_SERVICE_HOST__:__KUBERNETES_SERVICE_PORT__",
37              "k8s_auth_token": "__SERVICEACCOUNT_TOKEN__"
38         },
39         "kubernetes": {
40             "kubeconfig": "/etc/cni/net.d/__KUBECONFIG_FILENAME__"
41         }
42     }
43
44 ---
45
46 # This manifest installs the Calico etcd on the kubeadm master.  This uses a DaemonSet
47 # to force it to run on the master even when the master isn't schedulable, and uses
48 # nodeSelector to ensure it only runs on the master.
49 apiVersion: extensions/v1beta1
50 kind: DaemonSet
51 metadata:
52   name: calico-etcd
53   namespace: kube-system
54   labels:
55     k8s-app: calico-etcd
56 spec:
57   template:
58     metadata:
59       labels:
60         k8s-app: calico-etcd
61       annotations:
62         # Mark this pod as a critical add-on; when enabled, the critical add-on scheduler
63         # reserves resources for critical add-on pods so that they can be rescheduled after
64         # a failure.  This annotation works in tandem with the toleration below.
65         scheduler.alpha.kubernetes.io/critical-pod: ''
66     spec:
67       # Only run this pod on the master.
68       tolerations:
69       # this taint is set by all kubelets running `--cloud-provider=external`
70       # so we should tolerate it to schedule the calico pods
71       - key: node.cloudprovider.kubernetes.io/uninitialized
72         value: "true"
73         effect: NoSchedule
74       - key: node-role.kubernetes.io/master
75         effect: NoSchedule
76       # Allow this pod to be rescheduled while the node is in "critical add-ons only" mode.
77       # This, along with the annotation above marks this pod as a critical add-on.
78       - key: CriticalAddonsOnly
79         operator: Exists
80       nodeSelector:
81         node-role.kubernetes.io/master: ""
82       hostNetwork: true
83       containers:
84         - name: calico-etcd
85           image: quay.io/coreos/etcd:v3.1.10
86           env:
87             - name: CALICO_ETCD_IP
88               valueFrom:
89                 fieldRef:
90                   fieldPath: status.podIP
91           command: ["/bin/sh","-c"]
92           args: ["/usr/local/bin/etcd --name=calico --data-dir=/var/etcd/calico-data --advertise-client-urls=http://$CALICO_ETCD_IP:6666 --listen-client-urls=http://0.0.0.0:6666 --listen-peer-urls=http://0.0.0.0:6667"]
93           volumeMounts:
94             - name: var-etcd
95               mountPath: /var/etcd
96       volumes:
97         - name: var-etcd
98           hostPath:
99             path: /var/etcd
100
101 ---
102
103 # This manifest installs the Service which gets traffic to the Calico
104 # etcd.
105 apiVersion: v1
106 kind: Service
107 metadata:
108   labels:
109     k8s-app: calico-etcd
110   name: calico-etcd
111   namespace: kube-system
112 spec:
113   # Select the calico-etcd pod running on the master.
114   selector:
115     k8s-app: calico-etcd
116   # This ClusterIP needs to be known in advance, since we cannot rely
117   # on DNS to get access to etcd.
118   clusterIP: 10.96.232.136
119   ports:
120     - port: 6666
121
122 ---
123
124 # This manifest installs the calico/node container, as well
125 # as the Calico CNI plugins and network config on
126 # each master and worker node in a Kubernetes cluster.
127 kind: DaemonSet
128 apiVersion: extensions/v1beta1
129 metadata:
130   name: calico-node
131   namespace: kube-system
132   labels:
133     k8s-app: calico-node
134 spec:
135   selector:
136     matchLabels:
137       k8s-app: calico-node
138   template:
139     metadata:
140       labels:
141         k8s-app: calico-node
142       annotations:
143         # Mark this pod as a critical add-on; when enabled, the critical add-on scheduler
144         # reserves resources for critical add-on pods so that they can be rescheduled after
145         # a failure.  This annotation works in tandem with the toleration below.
146         scheduler.alpha.kubernetes.io/critical-pod: ''
147     spec:
148       hostNetwork: true
149       tolerations:
150       # this taint is set by all kubelets running `--cloud-provider=external`
151       # so we should tolerate it to schedule the calico pods
152       - key: node.cloudprovider.kubernetes.io/uninitialized
153         value: "true"
154         effect: NoSchedule
155       - key: node-role.kubernetes.io/master
156         effect: NoSchedule
157       # Allow this pod to be rescheduled while the node is in "critical add-ons only" mode.
158       # This, along with the annotation above marks this pod as a critical add-on.
159       - key: CriticalAddonsOnly
160         operator: Exists
161       serviceAccountName: calico-cni-plugin
162       # Minimize downtime during a rolling upgrade or deletion; tell Kubernetes to do a "force
163       # deletion": https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods.
164       terminationGracePeriodSeconds: 0
165       containers:
166         # Runs calico/node container on each Kubernetes node.  This
167         # container programs network policy and routes on each
168         # host.
169         - name: calico-node
170           image: quay.io/calico/node:v2.6.3
171           env:
172             # The location of the Calico etcd cluster.
173             - name: ETCD_ENDPOINTS
174               valueFrom:
175                 configMapKeyRef:
176                   name: calico-config
177                   key: etcd_endpoints
178             # Enable BGP.  Disable to enforce policy only.
179             - name: CALICO_NETWORKING_BACKEND
180               valueFrom:
181                 configMapKeyRef:
182                   name: calico-config
183                   key: calico_backend
184             # Cluster type to identify the deployment type
185             - name: CLUSTER_TYPE
186               value: "kubeadm,bgp"
187             # Set noderef for node controller.
188             - name: CALICO_K8S_NODE_REF
189               valueFrom:
190                 fieldRef:
191                   fieldPath: spec.nodeName
192             # Disable file logging so `kubectl logs` works.
193             - name: CALICO_DISABLE_FILE_LOGGING
194               value: "true"
195             # Set Felix endpoint to host default action to ACCEPT.
196             - name: FELIX_DEFAULTENDPOINTTOHOSTACTION
197               value: "ACCEPT"
198             # Configure the IP Pool from which Pod IPs will be chosen.
199             - name: CALICO_IPV4POOL_CIDR
200               value: "192.168.0.0/16"
201             - name: CALICO_IPV4POOL_IPIP
202               value: "always"
203             # Disable IPv6 on Kubernetes.
204             - name: FELIX_IPV6SUPPORT
205               value: "false"
206             # Set MTU for tunnel device used if ipip is enabled
207             - name: FELIX_IPINIPMTU
208               value: "1440"
209             # Set Felix logging to "info"
210             - name: FELIX_LOGSEVERITYSCREEN
211               value: "info"
212             # Auto-detect the BGP IP address.
213             - name: IP
214               value: ""
215             - name: FELIX_HEALTHENABLED
216               value: "true"
217           securityContext:
218             privileged: true
219           resources:
220             requests:
221               cpu: 250m
222           livenessProbe:
223             httpGet:
224               path: /liveness
225               port: 9099
226             periodSeconds: 10
227             initialDelaySeconds: 10
228             failureThreshold: 6
229           readinessProbe:
230             httpGet:
231               path: /readiness
232               port: 9099
233             periodSeconds: 10
234           volumeMounts:
235             - mountPath: /lib/modules
236               name: lib-modules
237               readOnly: true
238             - mountPath: /var/run/calico
239               name: var-run-calico
240               readOnly: false
241         # This container installs the Calico CNI binaries
242         # and CNI network config file on each node.
243         - name: install-cni
244           image: quay.io/calico/cni:v1.11.1
245           command: ["/install-cni.sh"]
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             # The CNI network config to install on each node.
254             - name: CNI_NETWORK_CONFIG
255               valueFrom:
256                 configMapKeyRef:
257                   name: calico-config
258                   key: cni_network_config
259           volumeMounts:
260             - mountPath: /host/opt/cni/bin
261               name: cni-bin-dir
262             - mountPath: /host/etc/cni/net.d
263               name: cni-net-dir
264       volumes:
265         # Used by calico/node.
266         - name: lib-modules
267           hostPath:
268             path: /lib/modules
269         - name: var-run-calico
270           hostPath:
271             path: /var/run/calico
272         # Used to install CNI.
273         - name: cni-bin-dir
274           hostPath:
275             path: /opt/cni/bin
276         - name: cni-net-dir
277           hostPath:
278             path: /etc/cni/net.d
279
280 ---
281
282 # This manifest deploys the Calico Kubernetes controllers.
283 # See https://github.com/projectcalico/kube-controllers
284 apiVersion: extensions/v1beta1
285 kind: Deployment
286 metadata:
287   name: calico-kube-controllers
288   namespace: kube-system
289   labels:
290     k8s-app: calico-kube-controllers
291 spec:
292   # The controllers can only have a single active instance.
293   replicas: 1
294   strategy:
295     type: Recreate
296   template:
297     metadata:
298       name: calico-kube-controllers
299       namespace: kube-system
300       labels:
301         k8s-app: calico-kube-controllers
302       annotations:
303         # Mark this pod as a critical add-on; when enabled, the critical add-on scheduler
304         # reserves resources for critical add-on pods so that they can be rescheduled after
305         # a failure.  This annotation works in tandem with the toleration below.
306         scheduler.alpha.kubernetes.io/critical-pod: ''
307     spec:
308       # The controllers must run in the host network namespace so that
309       # it isn't governed by policy that would prevent it from working.
310       hostNetwork: true
311       tolerations:
312       # this taint is set by all kubelets running `--cloud-provider=external`
313       # so we should tolerate it to schedule the calico pods
314       - key: node.cloudprovider.kubernetes.io/uninitialized
315         value: "true"
316         effect: NoSchedule
317       - key: node-role.kubernetes.io/master
318         effect: NoSchedule
319       # Allow this pod to be rescheduled while the node is in "critical add-ons only" mode.
320       # This, along with the annotation above marks this pod as a critical add-on.
321       - key: CriticalAddonsOnly
322         operator: Exists
323       serviceAccountName: calico-kube-controllers
324       containers:
325         - name: calico-kube-controllers
326           image: quay.io/calico/kube-controllers:v1.0.1
327           env:
328             # The location of the Calico etcd cluster.
329             - name: ETCD_ENDPOINTS
330               valueFrom:
331                 configMapKeyRef:
332                   name: calico-config
333                   key: etcd_endpoints
334             # The location of the Kubernetes API.  Use the default Kubernetes
335             # service for API access.
336             - name: K8S_API
337               value: "https://kubernetes.default:443"
338             # Choose which controllers to run.
339             - name: ENABLED_CONTROLLERS
340               value: policy,profile,workloadendpoint,node
341             # Since we're running in the host namespace and might not have KubeDNS
342             # access, configure the container's /etc/hosts to resolve
343             # kubernetes.default to the correct service clusterIP.
344             - name: CONFIGURE_ETC_HOSTS
345               value: "true"
346
347 ---
348
349 # This deployment turns off the old "policy-controller". It should remain at 0 replicas, and then
350 # be removed entirely once the new kube-controllers deployment has been deployed above.
351 apiVersion: extensions/v1beta1
352 kind: Deployment
353 metadata:
354   name: calico-policy-controller
355   namespace: kube-system
356   labels:
357     k8s-app: calico-policy-controller
358 spec:
359   # Turn this deployment off in favor of the kube-controllers deployment above.
360   replicas: 0
361   strategy:
362     type: Recreate
363   template:
364     metadata:
365       name: calico-policy-controller
366       namespace: kube-system
367       labels:
368         k8s-app: calico-policy-controller
369     spec:
370       hostNetwork: true
371       serviceAccountName: calico-kube-controllers
372       containers:
373         - name: calico-policy-controller
374           image: quay.io/calico/kube-controllers:v1.0.1
375           env:
376             - name: ETCD_ENDPOINTS
377               valueFrom:
378                 configMapKeyRef:
379                   name: calico-config
380                   key: etcd_endpoints
381
382 ---
383
384 apiVersion: rbac.authorization.k8s.io/v1beta1
385 kind: ClusterRoleBinding
386 metadata:
387   name: calico-cni-plugin
388 roleRef:
389   apiGroup: rbac.authorization.k8s.io
390   kind: ClusterRole
391   name: calico-cni-plugin
392 subjects:
393 - kind: ServiceAccount
394   name: calico-cni-plugin
395   namespace: kube-system
396
397 ---
398
399 kind: ClusterRole
400 apiVersion: rbac.authorization.k8s.io/v1beta1
401 metadata:
402   name: calico-cni-plugin
403 rules:
404   - apiGroups: [""]
405     resources:
406       - pods
407       - nodes
408     verbs:
409       - get
410
411 ---
412
413 apiVersion: v1
414 kind: ServiceAccount
415 metadata:
416   name: calico-cni-plugin
417   namespace: kube-system
418
419 ---
420
421 apiVersion: rbac.authorization.k8s.io/v1beta1
422 kind: ClusterRoleBinding
423 metadata:
424   name: calico-kube-controllers
425 roleRef:
426   apiGroup: rbac.authorization.k8s.io
427   kind: ClusterRole
428   name: calico-kube-controllers
429 subjects:
430 - kind: ServiceAccount
431   name: calico-kube-controllers
432   namespace: kube-system
433
434 ---
435
436 kind: ClusterRole
437 apiVersion: rbac.authorization.k8s.io/v1beta1
438 metadata:
439   name: calico-kube-controllers
440 rules:
441   - apiGroups:
442     - ""
443     - extensions
444     resources:
445       - pods
446       - namespaces
447       - networkpolicies
448       - nodes
449     verbs:
450       - watch
451       - list
452
453 ---
454
455 apiVersion: v1
456 kind: ServiceAccount
457 metadata:
458   name: calico-kube-controllers
459   namespace: kube-system