环境信息:
我在mac上用virtualbox构建我的k8s集群。节点os是centos7.3。有两个节点和一个主节点,所有网络都是Net(可以访问公共网络)和Host-Only(可以访问内部网络).IP信息如下:
主
network enp0s3:192.168.99.100/24(仅限主机的网络,node1和node2可以访问此IP)
network enp0s8:10.0.3.15/24(网络网)
的节点1
network enp0s3:192.168.57.3/24(仅限主机网络,主站和node1可以访问此IP)
network enp0s8:10.0.3.16/24(Net network)
的节点2:
network enp0s3:192.168.58.2/24(仅限主机网络,主站和node1可以访问此IP)
network enp0s8:10.0.3.17/24(网络网络)
k8s版本是:
kubernetes(v1.5.2),ectd(3.1.7),flannel(0.7.0)。
在主设备上设置网络:
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上设置: /run/flannel/subnet.env:
FLANNEL_NETWORK=172.17.0.0/16
FLANNEL_SUBNET=172.17.50.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.58.2 -ip-masq=true"
node1'路线:
flannel0:172.17.94.0/16
docker0: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
然后,节点1上的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):
我不知道为什么节点无法访问法兰绒。希望得到帮助,谢谢。