Kubernetes集群搭建之CNI-Flanneld部署篇 (2)

相继启动各节点的服务 注意启动flannel再重启docker 才会覆盖docker0网桥

[root@master-01 ~]# systemctl daemon-reload[root@master-01 ~]# systemctl start flanneld[root@master-01 ~]# systemctl enable flanneld[root@master-01 ~]# systemctl restart dockerCreated symlink from /etc/systemd/system/multi-user.target.wants/flanneld.service to /usr/lib/systemd/system/flanneld.service.[root@master-01 ~]# systemctl restart docker

flannel服务启动时主要做了以下几步的工作: 从etcd中获取network的配置信息 划分subnet,并在etcd中进行注册 将子网信息记录到/run/flannel/subnet.env中,以保证各个节点的flanneld IP不会重复分配

7. 验证服务

# master-01[root@master-01 ~]# ip addr2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:0c:29:72:13:72 brd ff:ff:ff:ff:ff:ffinet 192.168.209.130/24 brd 192.168.209.255 scope global noprefixroute ens33valid_lft forever preferred_lft foreverinet6 fe80::5bba:68b5:e255:a636/64 scope link tentative noprefixroute dadfailed valid_lft forever preferred_lft foreverinet6 fe80::23a0:4782:75a7:43b/64 scope link tentative noprefixroute dadfailed valid_lft forever preferred_lft foreverinet6 fe80::46a2:a117:34d9:db1a/64 scope link noprefixroute valid_lft forever preferred_lft forever3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default link/ether 02:42:3e:8f:c7:39 brd ff:ff:ff:ff:ff:ffinet 172.17.58.1/24 brd 172.17.58.255 scope global docker0valid_lft forever preferred_lft forever4: flannel.1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN group default link/ether 7e:2b:b9:3c:ce:36 brd ff:ff:ff:ff:ff:ffinet 172.17.58.0/32 scope global flannel.1valid_lft forever preferred_lft foreverinet6 fe80::7c2b:b9ff:fe3c:ce36/64 scope link valid_lft forever preferred_lft forever# master-02[root@master-02 ~]# ip addr2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:0c:29:ac:58:9d brd ff:ff:ff:ff:ff:ffinet 192.168.209.131/24 brd 192.168.209.255 scope global noprefixroute ens33valid_lft forever preferred_lft foreverinet6 fe80::5bba:68b5:e255:a636/64 scope link tentative noprefixroute dadfailed valid_lft forever preferred_lft foreverinet6 fe80::23a0:4782:75a7:43b/64 scope link tentative noprefixroute dadfailed valid_lft forever preferred_lft foreverinet6 fe80::46a2:a117:34d9:db1a/64 scope link tentative noprefixroute dadfailed valid_lft forever preferred_lft forever3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default link/ether 02:42:32:c7:25:ca brd ff:ff:ff:ff:ff:ffinet 172.17.44.1/24 brd 172.17.44.255 scope global docker0valid_lft forever preferred_lft forever4: flannel.1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN group default link/ether 62:c3:35:ec:17:54 brd ff:ff:ff:ff:ff:ffinet 172.17.44.0/32 scope global flannel.1valid_lft forever preferred_lft foreverinet6 fe80::60c3:35ff:feec:1754/64 scope link valid_lft forever preferred_lft forever

需要确保docker0和flanneld在同一个网段

测试不同节点互通,在master-01上ping另外几个节点的docker0 ip

[root@master-01 ~]# ping 172.17.44.1PING 172.17.44.1 (172.17.44.1) 56(84) bytes of data.64 bytes from 172.17.44.1: icmp_seq=1 ttl=64 time=2.03 ms^C--- 172.17.44.1 ping statistics ---2 packets transmitted, 2 received, 0% packet loss, time 1001msrtt min/avg/max/mdev = 0.441/1.236/2.032/0.796 ms[root@master-01 ~]# ping 172.17.79.1PING 172.17.79.1 (172.17.79.1) 56(84) bytes of data.64 bytes from 172.17.79.1: icmp_seq=1 ttl=64 time=0.919 ms^C--- 172.17.79.1 ping statistics ---1 packets transmitted, 1 received, 0% packet loss, time 0msrtt min/avg/max/mdev = 0.919/0.919/0.919/0.000 ms[root@master-01 ~]# ping 172.17.47.1PING 172.17.47.1 (172.17.47.1) 56(84) bytes of data.64 bytes from 172.17.47.1: icmp_seq=1 ttl=64 time=0.369 ms^C--- 172.17.47.1 ping statistics ---1 packets transmitted, 1 received, 0% packet loss, time 0msrtt min/avg/max/mdev = 0.369/0.369/0.369/0.000 ms

如果能通说明Flannel部署成功。如果不通检查下日志:journalctl -u flannel或 tailf /var/log/messages

最后我们来看下etcd中保存的网段信息

[root@master-01 ~]# etcdctl --ca-file=http://www.likecs.com/etc/etcd/ssl/ca.pem --cert-file=http://www.likecs.com/etc/etcd/ssl/server.pem --key-file=http://www.likecs.com/etc/etcd/ssl/server-key.pem --endpoints="https://192.168.209.130:2379,https://192.168.209.131:2379,https://192.168.209.132:2379" ls /coreos.com/network/subnets/coreos.com/network/subnets/172.17.47.0-24/coreos.com/network/subnets/172.17.58.0-24/coreos.com/network/subnets/172.17.44.0-24/coreos.com/network/subnets/172.17.79.0-24[root@master-01 ~]# etcdctl --ca-file=http://www.likecs.com/etc/etcd/ssl/ca.pem --cert-file=http://www.likecs.com/etc/etcd/ssl/server.pem --key-file=http://www.likecs.com/etc/etcd/ssl/server-key.pem --endpoints="https://192.168.209.130:2379,https://192.168.209.131:2379,https://192.168.209.132:2379" get /coreos.com/network/subnets/172.17.47.0-24{"PublicIP":"192.168.209.133","BackendType":"vxlan","BackendData":{"VtepMAC":"8a:b1:a7:26:fd:33"}}[root@master-01 ~]# etcdctl --ca-file=http://www.likecs.com/etc/etcd/ssl/ca.pem --cert-file=http://www.likecs.com/etc/etcd/ssl/server.pem --key-file=http://www.likecs.com/etc/etcd/ssl/server-key.pem --endpoints="https://192.168.209.130:2379,https://192.168.209.131:2379,https://192.168.209.132:2379" get /coreos.com/network/subnets/172.17.58.0-24{"PublicIP":"192.168.209.130","BackendType":"vxlan","BackendData":{"VtepMAC":"7e:2b:b9:3c:ce:36"}}[root@master-01 ~]# etcdctl --ca-file=http://www.likecs.com/etc/etcd/ssl/ca.pem --cert-file=http://www.likecs.com/etc/etcd/ssl/server.pem --key-file=http://www.likecs.com/etc/etcd/ssl/server-key.pem --endpoints="https://192.168.209.130:2379,https://192.168.209.131:2379,https://192.168.209.132:2379" get /coreos.com/network/subnets/172.17.44.0-24{"PublicIP":"192.168.209.131","BackendType":"vxlan","BackendData":{"VtepMAC":"62:c3:35:ec:17:54"}}[root@master-01 ~]# etcdctl --ca-file=http://www.likecs.com/etc/etcd/ssl/ca.pem --cert-file=http://www.likecs.com/etc/etcd/ssl/server.pem --key-file=http://www.likecs.com/etc/etcd/ssl/server-key.pem --endpoints="https://192.168.209.130:2379,https://192.168.209.131:2379,https://192.168.209.132:2379" get /coreos.com/network/subnets/172.17.79.0-24{"PublicIP":"192.168.209.132","BackendType":"vxlan","BackendData":{"VtepMAC":"02:a0:14:9f:ff:fe"}}

好了,到这一步我们就完成了flanneld的部署,下一章介绍master集群的部署,敬请期待,谢谢!

END

如果你觉得文章还不错,请大家点『好看』分享下。你的肯定是我最大的鼓励和支持。

image

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwdxpd.html