Kubernetes单机部署之flanneldeployment

旧巷老猫 提交于 2020-08-16 02:02:22

早上从笔记本电脑的虚拟机共享目录VirtualLocalShare中找到了以前做实验用的kube-flannel.yml文件,特将这个文件传到台式机的虚拟机上,以完成昨日Kubernetes单机部署的flannel deployment。
由于国情原因,quay.io 是无法访问的,因此我找了个还能访问的国内镜像点,是李振良先生的提供的,不过flannel版本有点儿老,以下是我修改kube-flannel.yml后的文件内容:

[root@kubernetes-master ~]# cat -n kube-flannel.yml
1 ---
2 kind: ClusterRole
3 apiVersion: rbac.authorization.k8s.io/v1beta1
4 metadata:
5 name: flannel
6 rules:
7 - apiGroups:
8 - ""
9 resources:
10 - pods
11 verbs:
12 - get
13 - apiGroups:
14 - ""
15 resources:
16 - nodes
17 verbs:
18 - list
19 - watch
20 - apiGroups:
21 - ""
22 resources:
23 - nodes/status
24 verbs:
25 - patch
26 ---
27 kind: ClusterRoleBinding
28 apiVersion: rbac.authorization.k8s.io/v1beta1
29 metadata:
30 name: flannel
31 roleRef:
32 apiGroup: rbac.authorization.k8s.io
33 kind: ClusterRole
34 name: flannel
35 subjects:
36 - kind: ServiceAccount
37 name: flannel
38 namespace: kube-system
39 ---
40 apiVersion: v1
41 kind: ServiceAccount
42 metadata:
43 name: flannel
44 namespace: kube-system
45 ---
46 kind: ConfigMap
47 apiVersion: v1
48 metadata:
49 name: kube-flannel-cfg
50 namespace: kube-system
51 labels:
52 tier: node
53 app: flannel
54 data:
55 cni-conf.json: |
56 {
57 "name": "cbr0",
58 "plugins": [
59 {
60 "type": "flannel",
61 "delegate": {
62 "hairpinMode": true,
63 "isDefaultGateway": true
64 }
65 },
66 {
67 "type": "portmap",
68 "capabilities": {
69 "portMappings": true
70 }
71 }
72 ]
73 }
74 net-conf.json: |
75 {
76 "Network": "10.244.0.0/16",
77 "Backend": {
78 "Type": "vxlan"
79 }
80 }
81 ---
82 apiVersion: extensions/v1beta1
83 kind: DaemonSet
84 metadata:
85 name: kube-flannel-ds-amd64
86 namespace: kube-system
87 labels:
88 tier: node
89 app: flannel
90 spec:
91 template:
92 metadata:
93 labels:
94 tier: node
95 app: flannel
96 spec:
97 hostNetwork: true
98 nodeSelector:
99 beta.kubernetes.io/arch: amd64
100 tolerations:
101 - operator: Exists
102 effect: NoSchedule
103 serviceAccountName: flannel
104 initContainers:
105 - name: install-cni
106 image: lizhenliang/flannel:v0.11.0-amd64
107 command:
108 - cp
109 args:
110 - -f
111 - /etc/kube-flannel/cni-conf.json
112 - /etc/cni/net.d/10-flannel.conflist
113 volumeMounts:
114 - name: cni
115 mountPath: /etc/cni/net.d
116 - name: flannel-cfg
117 mountPath: /etc/kube-flannel/
118 containers:
119 - name: kube-flannel
120 image: lizhenliang/flannel:v0.11.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
159 ---
160 apiVersion: extensions/v1beta1
161 kind: DaemonSet
162 metadata:
163 name: kube-flannel-ds-arm64
164 namespace: kube-system
165 labels:
166 tier: node
167 app: flannel
168 spec:
169 template:
170 metadata:
171 labels:
172 tier: node
173 app: flannel
174 spec:
175 hostNetwork: true
176 nodeSelector:
177 beta.kubernetes.io/arch: arm64
178 tolerations:
179 - operator: Exists
180 effect: NoSchedule
181 serviceAccountName: flannel
182 initContainers:
183 - name: install-cni
184 image: quay.io/coreos/flannel:v0.11.0-arm64
185 command:
186 - cp
187 args:
188 - -f
189 - /etc/kube-flannel/cni-conf.json
190 - /etc/cni/net.d/10-flannel.conflist
191 volumeMounts:
192 - name: cni
193 mountPath: /etc/cni/net.d
194 - name: flannel-cfg
195 mountPath: /etc/kube-flannel/
196 containers:
197 - name: kube-flannel
198 image: quay.io/coreos/flannel:v0.11.0-arm64
199 command:
200 - /opt/bin/flanneld
201 args:
202 - --ip-masq
203 - --kube-subnet-mgr
204 resources:
205 requests:
206 cpu: "100m"
207 memory: "50Mi"
208 limits:
209 cpu: "100m"
210 memory: "50Mi"
211 securityContext:
212 privileged: true
213 env:
214 - name: POD_NAME
215 valueFrom:
216 fieldRef:
217 fieldPath: metadata.name
218 - name: POD_NAMESPACE
219 valueFrom:
220 fieldRef:
221 fieldPath: metadata.namespace
222 volumeMounts:
223 - name: run
224 mountPath: /run
225 - name: flannel-cfg
226 mountPath: /etc/kube-flannel/
227 volumes:
228 - name: run
229 hostPath:
230 path: /run
231 - name: cni
232 hostPath:
233 path: /etc/cni/net.d
234 - name: flannel-cfg
235 configMap:
236 name: kube-flannel-cfg
237 ---
238 apiVersion: extensions/v1beta1
239 kind: DaemonSet
240 metadata:
241 name: kube-flannel-ds-arm
242 namespace: kube-system
243 labels:
244 tier: node
245 app: flannel
246 spec:
247 template:
248 metadata:
249 labels:
250 tier: node
251 app: flannel
252 spec:
253 hostNetwork: true
254 nodeSelector:
255 beta.kubernetes.io/arch: arm
256 tolerations:
257 - operator: Exists
258 effect: NoSchedule
259 serviceAccountName: flannel
260 initContainers:
261 - name: install-cni
262 image: quay.io/coreos/flannel:v0.11.0-arm
263 command:
264 - cp
265 args:
266 - -f
267 - /etc/kube-flannel/cni-conf.json
268 - /etc/cni/net.d/10-flannel.conflist
269 volumeMounts:
270 - name: cni
271 mountPath: /etc/cni/net.d
272 - name: flannel-cfg
273 mountPath: /etc/kube-flannel/
274 containers:
275 - name: kube-flannel
276 image: quay.io/coreos/flannel:v0.11.0-arm
277 command:
278 - /opt/bin/flanneld
279 args:
280 - --ip-masq
281 - --kube-subnet-mgr
282 resources:
283 requests:
284 cpu: "100m"
285 memory: "50Mi"
286 limits:
287 cpu: "100m"
288 memory: "50Mi"
289 securityContext:
290 privileged: true
291 env:
292 - name: POD_NAME
293 valueFrom:
294 fieldRef:
295 fieldPath: metadata.name
296 - name: POD_NAMESPACE
297 valueFrom:
298 fieldRef:
299 fieldPath: metadata.namespace
300 volumeMounts:
301 - name: run
302 mountPath: /run
303 - name: flannel-cfg
304 mountPath: /etc/kube-flannel/
305 volumes:
306 - name: run
307 hostPath:
308 path: /run
309 - name: cni
310 hostPath:
311 path: /etc/cni/net.d
312 - name: flannel-cfg
313 configMap:
314 name: kube-flannel-cfg
315 ---
316 apiVersion: extensions/v1beta1
317 kind: DaemonSet
318 metadata:
319 name: kube-flannel-ds-ppc64le
320 namespace: kube-system
321 labels:
322 tier: node
323 app: flannel
324 spec:
325 template:
326 metadata:
327 labels:
328 tier: node
329 app: flannel
330 spec:
331 hostNetwork: true
332 nodeSelector:
333 beta.kubernetes.io/arch: ppc64le
334 tolerations:
335 - operator: Exists
336 effect: NoSchedule
337 serviceAccountName: flannel
338 initContainers:
339 - name: install-cni
340 image: quay.io/coreos/flannel:v0.11.0-ppc64le
341 command:
342 - cp
343 args:
344 - -f
345 - /etc/kube-flannel/cni-conf.json
346 - /etc/cni/net.d/10-flannel.conflist
347 volumeMounts:
348 - name: cni
349 mountPath: /etc/cni/net.d
350 - name: flannel-cfg
351 mountPath: /etc/kube-flannel/
352 containers:
353 - name: kube-flannel
354 image: quay.io/coreos/flannel:v0.11.0-ppc64le
355 command:
356 - /opt/bin/flanneld
357 args:
358 - --ip-masq
359 - --kube-subnet-mgr
360 resources:
361 requests:
362 cpu: "100m"
363 memory: "50Mi"
364 limits:
365 cpu: "100m"
366 memory: "50Mi"
367 securityContext:
368 privileged: true
369 env:
370 - name: POD_NAME
371 valueFrom:
372 fieldRef:
373 fieldPath: metadata.name
374 - name: POD_NAMESPACE
375 valueFrom:
376 fieldRef:
377 fieldPath: metadata.namespace
378 volumeMounts:
379 - name: run
380 mountPath: /run
381 - name: flannel-cfg
382 mountPath: /etc/kube-flannel/
383 volumes:
384 - name: run
385 hostPath:
386 path: /run
387 - name: cni
388 hostPath:
389 path: /etc/cni/net.d
390 - name: flannel-cfg
391 configMap:
392 name: kube-flannel-cfg
393 ---
394 apiVersion: extensions/v1beta1
395 kind: DaemonSet
396 metadata:
397 name: kube-flannel-ds-s390x
398 namespace: kube-system
399 labels:
400 tier: node
401 app: flannel
402 spec:
403 template:
404 metadata:
405 labels:
406 tier: node
407 app: flannel
408 spec:
409 hostNetwork: true
410 nodeSelector:
411 beta.kubernetes.io/arch: s390x
412 tolerations:
413 - operator: Exists
414 effect: NoSchedule
415 serviceAccountName: flannel
416 initContainers:
417 - name: install-cni
418 image: quay.io/coreos/flannel:v0.11.0-s390x
419 command:
420 - cp
421 args:
422 - -f
423 - /etc/kube-flannel/cni-conf.json
424 - /etc/cni/net.d/10-flannel.conflist
425 volumeMounts:
426 - name: cni
427 mountPath: /etc/cni/net.d
428 - name: flannel-cfg
429 mountPath: /etc/kube-flannel/
430 containers:
431 - name: kube-flannel
432 image: quay.io/coreos/flannel:v0.11.0-s390x
433 command:
434 - /opt/bin/flanneld
435 args:
436 - --ip-masq
437 - --kube-subnet-mgr
438 resources:
439 requests:
440 cpu: "100m"
441 memory: "50Mi"
442 limits:
443 cpu: "100m"
444 memory: "50Mi"
445 securityContext:
446 privileged: true
447 env:
448 - name: POD_NAME
449 valueFrom:
450 fieldRef:
451 fieldPath: metadata.name
452 - name: POD_NAMESPACE
453 valueFrom:
454 fieldRef:
455 fieldPath: metadata.namespace
456 volumeMounts:
457 - name: run
458 mountPath: /run
459 - name: flannel-cfg
460 mountPath: /etc/kube-flannel/
461 volumes:
462 - name: run
463 hostPath:
464 path: /run
465 - name: cni
466 hostPath:
467 path: /etc/cni/net.d
468 - name: flannel-cfg
469 configMap:
470 name: kube-flannel-cfg
[root@kubernetes-master ~]#






















































































































































































































































































































































































































































































flannel的deployment过程如下:
[root@kubernetes-master ~]# kubectl apply -f kube-flannel.yml
clusterrole.rbac.authorization.k8s.io/flannel created
clusterrolebinding.rbac.authorization.k8s.io/flannel created
serviceaccount/flannel created
configmap/kube-flannel-cfg created
daemonset.extensions/kube-flannel-ds-amd64 created
daemonset.extensions/kube-flannel-ds-arm64 created
daemonset.extensions/kube-flannel-ds-arm created
daemonset.extensions/kube-flannel-ds-ppc64le created
daemonset.extensions/kube-flannel-ds-s390x created
[root@kubernetes-master ~]# ps -ef|grep flannel
root 11839 1 0 23:26 ? 00:00:00 /usr/bin/flanneld -etcd-endpoints=http://127.0.0.1:2379 -etcd-prefix=/atomic.io/network
root 12668 12650 3 23:28 ? 00:00:00 /opt/bin/flanneld --ip-masq --kube-subnet-mgr
root 12746 9430 0 23:28 pts/0 00:00:00 grep --color=auto flannel
[root@kubernetes-master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
kubernetes-master Ready master 12h v1.15.0
[root@kubernetes-master ~]# kubectl get componentstatus
NAME STATUS MESSAGE ERROR
controller-manager Healthy ok
scheduler Healthy ok
etcd-0 Healthy {"health":"true"}
[root@kubernetes-master ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.aliyuncs.com/google_containers/kube-proxy v1.15.0 d235b23c3570 11 months ago 82.4MB
registry.aliyuncs.com/google_containers/kube-apiserver v1.15.0 201c7a840312 11 months ago 207MB
registry.aliyuncs.com/google_containers/kube-scheduler v1.15.0 2d3813851e87 11 months ago 81.1MB
registry.aliyuncs.com/google_containers/kube-controller-manager v1.15.0 8328bb49b652 11 months ago 159MB
lizhenliang/flannel v0.11.0-amd64 ff281650a721 16 months ago 52.6MB
registry.aliyuncs.com/google_containers/coredns 1.3.1 eb516548c180 16 months ago 40.3MB
registry.aliyuncs.com/google_containers/etcd 3.3.10 2c4adeb21b4f 18 months ago 258MB
registry.aliyuncs.com/google_containers/pause 3.1 da86e6ba6ca1 2 years ago 742kB
[root@kubernetes-master ~]# kubectl get pod -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-bccdc95cf-2g9rw 1/1 Running 0 12h
coredns-bccdc95cf-xzfrl 1/1 Running 0 12h
etcd-kubernetes-master 1/1 Running 2 12h
kube-apiserver-kubernetes-master 1/1 Running 2 12h
kube-controller-manager-kubernetes-master 1/1 Running 2 12h
kube-flannel-ds-amd64-t5prf 1/1 Running 0 115s
kube-proxy-npszc 1/1 Running 2 12h
kube-scheduler-kubernetes-master 1/1 Running 2 12h
[root@kubernetes-master ~]#










































孟伯,20200527

交流联系:微信 1807479153 ,QQ 1807479153

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!