CSIT-748 vnf-agent integration
[csit.git] / resources / templates / kubernetes / calico_v2.4.1.yaml
1 # Calico Version v2.4.1
2 # https://docs.projectcalico.org/v2.4/releases#v2.4.1
3 # This manifest includes the following component versions:
4 #   calico/node:v2.4.1
5 #   calico/cni:v1.10.0
6 #   calico/kube-policy-controller:v0.7.0
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       - key: node-role.kubernetes.io/master
70         effect: NoSchedule
71       # Allow this pod to be rescheduled while the node is in "critical add-ons only" mode.
72       # This, along with the annotation above marks this pod as a critical add-on.
73       - key: CriticalAddonsOnly
74         operator: Exists
75       nodeSelector:
76         node-role.kubernetes.io/master: ""
77       hostNetwork: true
78       containers:
79         - name: calico-etcd
80           image: quay.io/coreos/etcd:v3.1.10
81           env:
82             - name: CALICO_ETCD_IP
83               valueFrom:
84                 fieldRef:
85                   fieldPath: status.podIP
86           command: ["/bin/sh","-c"]
87           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"]
88           volumeMounts:
89             - name: var-etcd
90               mountPath: /var/etcd
91       volumes:
92         - name: var-etcd
93           hostPath:
94             path: /var/etcd
95
96 ---
97
98 # This manifest installs the Service which gets traffic to the Calico
99 # etcd.
100 apiVersion: v1
101 kind: Service
102 metadata:
103   labels:
104     k8s-app: calico-etcd
105   name: calico-etcd
106   namespace: kube-system
107 spec:
108   # Select the calico-etcd pod running on the master.
109   selector:
110     k8s-app: calico-etcd
111   # This ClusterIP needs to be known in advance, since we cannot rely
112   # on DNS to get access to etcd.
113   clusterIP: 10.96.232.136
114   ports:
115     - port: 6666
116
117 ---
118
119 # This manifest installs the calico/node container, as well
120 # as the Calico CNI plugins and network config on
121 # each master and worker node in a Kubernetes cluster.
122 kind: DaemonSet
123 apiVersion: extensions/v1beta1
124 metadata:
125   name: calico-node
126   namespace: kube-system
127   labels:
128     k8s-app: calico-node
129 spec:
130   selector:
131     matchLabels:
132       k8s-app: calico-node
133   template:
134     metadata:
135       labels:
136         k8s-app: calico-node
137       annotations:
138         # Mark this pod as a critical add-on; when enabled, the critical add-on scheduler
139         # reserves resources for critical add-on pods so that they can be rescheduled after
140         # a failure.  This annotation works in tandem with the toleration below.
141         scheduler.alpha.kubernetes.io/critical-pod: ''
142     spec:
143       hostNetwork: true
144       tolerations:
145       - key: node-role.kubernetes.io/master
146         effect: NoSchedule
147       # Allow this pod to be rescheduled while the node is in "critical add-ons only" mode.
148       # This, along with the annotation above marks this pod as a critical add-on.
149       - key: CriticalAddonsOnly
150         operator: Exists
151       serviceAccountName: calico-cni-plugin
152       containers:
153         # Runs calico/node container on each Kubernetes node.  This
154         # container programs network policy and routes on each
155         # host.
156         - name: calico-node
157           image: quay.io/calico/node:v2.4.1
158           env:
159             # The location of the Calico etcd cluster.
160             - name: ETCD_ENDPOINTS
161               valueFrom:
162                 configMapKeyRef:
163                   name: calico-config
164                   key: etcd_endpoints
165             # Enable BGP.  Disable to enforce policy only.
166             - name: CALICO_NETWORKING_BACKEND
167               valueFrom:
168                 configMapKeyRef:
169                   name: calico-config
170                   key: calico_backend
171             # Cluster type to identify the deployment type
172             - name: CLUSTER_TYPE
173               value: "kubeadm,bgp"
174             # Disable file logging so `kubectl logs` works.
175             - name: CALICO_DISABLE_FILE_LOGGING
176               value: "true"
177             # Set Felix endpoint to host default action to ACCEPT.
178             - name: FELIX_DEFAULTENDPOINTTOHOSTACTION
179               value: "ACCEPT"
180             # Configure the IP Pool from which Pod IPs will be chosen.
181             - name: CALICO_IPV4POOL_CIDR
182               value: "192.168.0.0/16"
183             - name: CALICO_IPV4POOL_IPIP
184               value: "always"
185             # Disable IPv6 on Kubernetes.
186             - name: FELIX_IPV6SUPPORT
187               value: "false"
188             # Set MTU for tunnel device used if ipip is enabled
189             - name: FELIX_IPINIPMTU
190               value: "1440"
191             # Set Felix logging to "info"
192             - name: FELIX_LOGSEVERITYSCREEN
193               value: "info"
194             - name: FELIX_HEALTHENABLED
195               value: "true"
196             # Auto-detect the BGP IP address.
197             - name: IP
198               value: ""
199           securityContext:
200             privileged: true
201           resources:
202             requests:
203               cpu: 250m
204           livenessProbe:
205             httpGet:
206               path: /liveness
207               port: 9099
208             periodSeconds: 10
209             initialDelaySeconds: 10
210             failureThreshold: 6
211           readinessProbe:
212             httpGet:
213               path: /readiness
214               port: 9099
215             periodSeconds: 10
216           volumeMounts:
217             - mountPath: /lib/modules
218               name: lib-modules
219               readOnly: true
220             - mountPath: /var/run/calico
221               name: var-run-calico
222               readOnly: false
223         # This container installs the Calico CNI binaries
224         # and CNI network config file on each node.
225         - name: install-cni
226           image: quay.io/calico/cni:v1.10.0
227           command: ["/install-cni.sh"]
228           env:
229             # The location of the Calico etcd cluster.
230             - name: ETCD_ENDPOINTS
231               valueFrom:
232                 configMapKeyRef:
233                   name: calico-config
234                   key: etcd_endpoints
235             # The CNI network config to install on each node.
236             - name: CNI_NETWORK_CONFIG
237               valueFrom:
238                 configMapKeyRef:
239                   name: calico-config
240                   key: cni_network_config
241           volumeMounts:
242             - mountPath: /host/opt/cni/bin
243               name: cni-bin-dir
244             - mountPath: /host/etc/cni/net.d
245               name: cni-net-dir
246       volumes:
247         # Used by calico/node.
248         - name: lib-modules
249           hostPath:
250             path: /lib/modules
251         - name: var-run-calico
252           hostPath:
253             path: /var/run/calico
254         # Used to install CNI.
255         - name: cni-bin-dir
256           hostPath:
257             path: /opt/cni/bin
258         - name: cni-net-dir
259           hostPath:
260             path: /etc/cni/net.d
261
262 ---
263
264 # This manifest deploys the Calico policy controller on Kubernetes.
265 # See https://github.com/projectcalico/k8s-policy
266 apiVersion: extensions/v1beta1
267 kind: Deployment
268 metadata:
269   name: calico-policy-controller
270   namespace: kube-system
271   labels:
272     k8s-app: calico-policy
273 spec:
274   # The policy controller can only have a single active instance.
275   replicas: 1
276   strategy:
277     type: Recreate
278   template:
279     metadata:
280       name: calico-policy-controller
281       namespace: kube-system
282       labels:
283         k8s-app: calico-policy-controller
284       annotations:
285         # Mark this pod as a critical add-on; when enabled, the critical add-on scheduler
286         # reserves resources for critical add-on pods so that they can be rescheduled after
287         # a failure.  This annotation works in tandem with the toleration below.
288         scheduler.alpha.kubernetes.io/critical-pod: ''
289     spec:
290       # The policy controller must run in the host network namespace so that
291       # it isn't governed by policy that would prevent it from working.
292       hostNetwork: true
293       tolerations:
294       - key: node-role.kubernetes.io/master
295         effect: NoSchedule
296       # Allow this pod to be rescheduled while the node is in "critical add-ons only" mode.
297       # This, along with the annotation above marks this pod as a critical add-on.
298       - key: CriticalAddonsOnly
299         operator: Exists
300       serviceAccountName: calico-policy-controller
301       containers:
302         - name: calico-policy-controller
303           image: quay.io/calico/kube-policy-controller:v0.7.0
304           env:
305             # The location of the Calico etcd cluster.
306             - name: ETCD_ENDPOINTS
307               valueFrom:
308                 configMapKeyRef:
309                   name: calico-config
310                   key: etcd_endpoints
311             # The location of the Kubernetes API.  Use the default Kubernetes
312             # service for API access.
313             - name: K8S_API
314               value: "https://kubernetes.default:443"
315             # Since we're running in the host namespace and might not have KubeDNS
316             # access, configure the container's /etc/hosts to resolve
317             # kubernetes.default to the correct service clusterIP.
318             - name: CONFIGURE_ETC_HOSTS
319               value: "true"
320 ---
321 apiVersion: rbac.authorization.k8s.io/v1beta1
322 kind: ClusterRoleBinding
323 metadata:
324   name: calico-cni-plugin
325 roleRef:
326   apiGroup: rbac.authorization.k8s.io
327   kind: ClusterRole
328   name: calico-cni-plugin
329 subjects:
330 - kind: ServiceAccount
331   name: calico-cni-plugin
332   namespace: kube-system
333 ---
334 kind: ClusterRole
335 apiVersion: rbac.authorization.k8s.io/v1beta1
336 metadata:
337   name: calico-cni-plugin
338   namespace: kube-system
339 rules:
340   - apiGroups: [""]
341     resources:
342       - pods
343       - nodes
344     verbs:
345       - get
346 ---
347 apiVersion: v1
348 kind: ServiceAccount
349 metadata:
350   name: calico-cni-plugin
351   namespace: kube-system
352 ---
353 apiVersion: rbac.authorization.k8s.io/v1beta1
354 kind: ClusterRoleBinding
355 metadata:
356   name: calico-policy-controller
357 roleRef:
358   apiGroup: rbac.authorization.k8s.io
359   kind: ClusterRole
360   name: calico-policy-controller
361 subjects:
362 - kind: ServiceAccount
363   name: calico-policy-controller
364   namespace: kube-system
365 ---
366 kind: ClusterRole
367 apiVersion: rbac.authorization.k8s.io/v1beta1
368 metadata:
369   name: calico-policy-controller
370   namespace: kube-system
371 rules:
372   - apiGroups:
373     - ""
374     - extensions
375     resources:
376       - pods
377       - namespaces
378       - networkpolicies
379     verbs:
380       - watch
381       - list
382 ---
383 apiVersion: v1
384 kind: ServiceAccount
385 metadata:
386   name: calico-policy-controller
387   namespace: kube-system