Add ansible scripts to deploy Kubernetes
[yardstick.git] / ansible / roles / init_kubeadm / templates / kube-flannel.yaml.j2
1 # Copyright (c) 2019 Intel Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 ---
15 kind: ClusterRole
16 apiVersion: rbac.authorization.k8s.io/v1beta1
17 metadata:
18   name: flannel
19 rules:
20   - apiGroups:
21       - ""
22     resources:
23       - pods
24     verbs:
25       - get
26   - apiGroups:
27       - ""
28     resources:
29       - nodes
30     verbs:
31       - list
32       - watch
33   - apiGroups:
34       - ""
35     resources:
36       - nodes/status
37     verbs:
38       - patch
39 ---
40 kind: ClusterRoleBinding
41 apiVersion: rbac.authorization.k8s.io/v1beta1
42 metadata:
43   name: flannel
44 roleRef:
45   apiGroup: rbac.authorization.k8s.io
46   kind: ClusterRole
47   name: flannel
48 subjects:
49 - kind: ServiceAccount
50   name: flannel
51   namespace: kube-system
52 ---
53 apiVersion: v1
54 kind: ServiceAccount
55 metadata:
56   name: flannel
57   namespace: kube-system
58 ---
59 kind: ConfigMap
60 apiVersion: v1
61 metadata:
62   name: kube-flannel-cfg
63   namespace: kube-system
64   labels:
65     tier: node
66     app: flannel
67 data:
68   cni-conf.json: |
69     {
70       "name": "cbr0",
71       "plugins": [
72         {
73           "type": "flannel",
74           "delegate": {
75             "hairpinMode": true,
76             "isDefaultGateway": true
77           }
78         },
79         {
80           "type": "portmap",
81           "capabilities": {
82             "portMappings": true
83           }
84         }
85       ]
86     }
87   net-conf.json: |
88     {
89       "Network": "{{ kubeadm_pod_network_cidr }}",
90       "Backend": {
91         "Type": "vxlan"
92       }
93     }
94 ---
95 apiVersion: extensions/v1beta1
96 kind: DaemonSet
97 metadata:
98   name: kube-flannel-ds
99   namespace: kube-system
100   labels:
101     tier: node
102     app: flannel
103 spec:
104   template:
105     metadata:
106       labels:
107         tier: node
108         app: flannel
109     spec:
110       hostNetwork: true
111       nodeSelector:
112         beta.kubernetes.io/arch: amd64
113       tolerations:
114       - key: node-role.kubernetes.io/master
115         operator: Exists
116         effect: NoSchedule
117       serviceAccountName: flannel
118       containers:
119       - name: kube-flannel
120         image: quay.io/coreos/flannel:v0.10.0-amd64
121         command:
122         - /opt/bin/flanneld
123         args:
124         - --ip-masq
125         - --kube-subnet-mgr
126         resources:
127           requests:
128             cpu: "100m"
129             memory: "50Mi"
130           limits:
131             cpu: "100m"
132             memory: "50Mi"
133         securityContext:
134           privileged: true
135         env:
136         - name: POD_NAME
137           valueFrom:
138             fieldRef:
139               fieldPath: metadata.name
140         - name: POD_NAMESPACE
141           valueFrom:
142             fieldRef:
143               fieldPath: metadata.namespace
144         volumeMounts:
145         - name: run
146           mountPath: /run
147         - name: flannel-cfg
148           mountPath: /etc/kube-flannel/
149       volumes:
150         - name: run
151           hostPath:
152             path: /run
153         - name: cni
154           hostPath:
155             path: /etc/cni/net.d
156         - name: flannel-cfg
157           configMap:
158             name: kube-flannel-cfg