0

环境信息:我在mac上用virtualbox构建了我的k8s集群。节点操作系统是centos7.3。有两个node和一个master,它们的网络都是Net(可以访问公网)和Host-Only(可以访问内网)。IP信息如下:
master:
network enp0s3 :192.168.99.100/24 ( Host-only网络,node1和node2可以访问这个IP)
network enp0s8 :10.0.3.15/24 (Net network)<br> node1:
network enp0s3 :192.168.57.3/24 (Host-only network,master和node1可以访问这个IP)
network enp0s8 :10.0.3.16/24(Net network)<br> node2:
network enp0s3 :192.168.58.2/24(Host-only network,master和node1可以访问这个IP)
network enp0s8 :10.0.3.17/24(网络)</p>

k8s版本为:
kubernetes(v1.5.2),ectd(3.1.7),flannel(0.7.0)。</p>

主机上的网络设置:
etcdctl set /atomic.io/network/config '{"Network":"172.17.0.0/16"}'

在 node1 上设置法兰绒:
/run/flannel/subnet.env

FLANNEL_NETWORK=172.17.0.0/16
FLANNEL_SUBNET=172.17.94.1/24
FLANNEL_MTU=1472
FLANNEL_IPMASQ=true

/etc/sysconfig/flanneld:

FLANNEL_ETCD_ENDPOINTS="http://192.168.99.100:2379"
FLANNEL_ETCD_PREFIX="/atomic.io/network"
FLANNEL_OPTIONS="-iface=enp0s3 -public-ip=192.168.57.3 -ip-masq=true"

在node2上设置flannel: /run/flannel/subnet.env:</p>

FLANNEL_NETWORK=172.17.0.0/16
FLANNEL_SUBNET=172.17.50.1/24
FLANNEL_MTU=1472
FLANNEL_IPMASQ=true

/etc/sysconfig/flanneld:</p>

FLANNEL_ETCD_ENDPOINTS="http://192.168.99.100:2379"
FLANNEL_ETCD_PREFIX="/atomic.io/network"
FLANNEL_OPTIONS="-iface=enp0s3 -public-ip=192.168.58.2 -ip-masq=true"

node1的路线:

法兰绒0:172.17.94.0/16
码头0:172.17.94.1/24

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.3.2 0.0.0.0 UG 100 0 0 enp0s8
10.0.3.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s8
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 flannel0
172.17.94.0 0.0.0.0 255.255.255.0 U 0 0 0 docker0
192.168.57.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s3

default via 10.0.3.2 dev enp0s8 proto static metric 100 
10.0.3.0/24 dev enp0s8 proto kernel scope link src 10.0.3.16 metric 100 
172.17.0.0/16 dev flannel0 proto kernel scope link src 172.17.94.0 
172.17.94.0/24 dev docker0 proto kernel scope link src 172.17.94.1 
192.168.57.0/24 dev enp0s3 proto kernel scope link src 192.168.57.3 metric 100 

node2的路由:
flannel0: 172.17.50.0/16
docker0: 172.17.50.1/24

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.3.2 0.0.0.0 UG 0 0 0 enp0s8
10.0.3.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s8
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 enp0s8
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 flannel0
172.17.0.0 0.0.0.0 255.255.0.0 U 1 0 0 flannel0
172.17.50.0 0.0.0.0 255.255.255.0 U 0 0 0 docker0
192.168.58.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s3

default via 10.0.3.2 dev enp0s8 
10.0.3.0/24 dev enp0s8 proto kernel scope link src 10.0.3.17 
169.254.0.0/16 dev enp0s8 scope link metric 1003 
172.17.0.0/16 dev flannel0 
172.17.0.0/16 dev flannel0 scope link metric 1 
172.17.50.0/24 dev docker0 proto kernel scope link src 172.17.50.1 
192.168.58.0/24 dev enp0s3 proto kernel scope link src 192.168.58.2 metric 100 

然后,在node1上Ping node2的docker ip(172.17.50.1)不正常,Ping node1的docker ip(172.17.94.1)也不正常。使用tcpdump查看网络,发现可能网络配置不正常。源ip和des ip应该是192.168.57.3(通过enp0s3)而不是10.0.3.16(通过enp0s8): 在此处输入图像描述

我不知道为什么节点不能通过flannel访问。希望得到帮助,谢谢。

4

0 回答 0