flannel cni 配置
flannel 以 DaemonSet 的形式运行在 Kubernetes 集群中。 由于我们的 etcd 集群启用了 TLS 认证,为了从 flannel 容器中能访问 etcd,我们先把 etcd 的 TLS 证书信息保存到 Kubernetes 的Secret 中。
之前是吧flannel以服务的形式部署在node节点上,这种模式每次新增节点的时候都要去部署一次flannel,显得比较麻烦,以pod形式部署,每次新增节点后,kubernetes会自动的部署flannel。
删除原有的网络组件,采用容器方式进行部署。
kube-controller-manager修改
1 | --allocate-node-cidrs=true |
参数:
- 1.是否应在云提供商上分配和设置Pod的CIDR
- 2.集群中Pod的CIDR范围。要求–allocate-node-cidrs为true
kube-controller-manager参数详细说明
kubelet 修改
kubelet修改两个配置文件,kubelet-config.yaml 文件已更新
kubelet.service启动文件
1 | --network-plugin=cni |
kubele参数详细说明
kube-proxy 修改子网
- kube-proxy-config.yaml
1
clusterCIDR: 10.244.0.0/16
首先停止node 的flananel、 kubelet、kube-proxy。在删除/etc/cni/net.d/、/run/flannel/subnet.env、/var/lib/cni/flannel 的历史文件,重启网卡,除了flannel不启动,其他均启动。全新安装不需要这么操作,flannel证书也不需要复制。二进制安装参考
下载cni插件
cni 插件下载,解压后,放在各个节点的 /opt/cni/bin 下。
1 | ls -l /opt/cni/bin/ |
flannel 部署
1 | wget https://raw.githubusercontent.com/coreos/flannel/v0.11.0/Documentation/kube-flannel.yml |
查看flannel安装情况
1 | # kubectl get po,svc -o wide |
查看节点的网络
node-01
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39# ifconfig
cni0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450
inet 10.244.6.1 netmask 255.255.255.0 broadcast 10.244.6.255
ether 42:56:73:73:c5:69 txqueuelen 1000 (Ethernet)
RX packets 121976 bytes 48185929 (45.9 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 143012 bytes 112170228 (106.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.21.17.41 netmask 255.255.240.0 broadcast 172.21.31.255
ether fa:16:3e:a0:b1:af txqueuelen 1000 (Ethernet)
RX packets 1878425 bytes 997129342 (950.9 MiB)
RX errors 0 dropped 29 overruns 0 frame 0
TX packets 1014950 bytes 378435170 (360.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
flannel.1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450
inet 10.244.6.0 netmask 255.255.255.255 broadcast 0.0.0.0
ether 32:83:f7:e6:de:77 txqueuelen 0 (Ethernet)
RX packets 207502 bytes 36217464 (34.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 242424 bytes 246992876 (235.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1 (Local Loopback)
RX packets 15889 bytes 7196484 (6.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 15889 bytes 7196484 (6.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vethb26f5960: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450
ether a6:a8:18:c3:f0:16 txqueuelen 0 (Ethernet)
RX packets 23 bytes 2075 (2.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 49 bytes 4330 (4.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0node-02
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39# ifconfig
cni0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450
inet 10.244.4.1 netmask 255.255.255.0 broadcast 10.244.4.255
ether 82:14:33:5c:b0:b7 txqueuelen 1000 (Ethernet)
RX packets 150228 bytes 747318135 (712.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 214837 bytes 209342880 (199.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.21.16.231 netmask 255.255.240.0 broadcast 172.21.31.255
ether fa:16:3e:d8:23:fe txqueuelen 1000 (Ethernet)
RX packets 10290258 bytes 3436274673 (3.2 GiB)
RX errors 0 dropped 19 overruns 0 frame 0
TX packets 9490095 bytes 3777352983 (3.5 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
flannel.1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450
inet 10.244.4.0 netmask 255.255.255.255 broadcast 0.0.0.0
ether ee:a3:ff:37:3a:61 txqueuelen 0 (Ethernet)
RX packets 280851 bytes 31096456 (29.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 262931 bytes 968429571 (923.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1 (Local Loopback)
RX packets 653134 bytes 200562497 (191.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 653134 bytes 200562497 (191.2 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
veth8aa15f82: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450
ether fa:23:1e:b0:65:20 txqueuelen 0 (Ethernet)
RX packets 49191 bytes 4622232 (4.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 53647 bytes 19011709 (18.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0