[root@node1 ~]# etcdctl ls /kube-centos/network/subnets/kube-centos/network/subnets/172.33.68.0-24/kube-centos/network/subnets/172.33.31.0-24/kube-centos/network/subnets/172.33.96.0-24
而每个node上的Pod子网是根据我们在安装flannel时配置来划分的,在etcd中查看该配置:
[root@node1 ~]# etcdctl get /kube-centos/network/config{"Network":"172.33.0.0/16","SubnetLen":24,"Backend":{"Type":"host-gw"}}
[root@node1 ~]# ip addr1:lo:<LOOPBACK,UP,LOWER_UP>mtu65536qdiscnoqueuestateUNKNOWNqlen1link/loopback00:00:00:00:00:00brd00:00:00:00:00:00inet127.0.0.1/8scopehostlovalid_lftforeverpreferred_lftforeverinet6::1/128scopehostvalid_lftforeverpreferred_lftforever2:eth0:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscpfifo_faststateUPqlen1000link/ether52:54:00:00:57:32brdff:ff:ff:ff:ff:ffinet10.0.2.15/24brd10.0.2.255scopeglobaldynamiceth0valid_lft85095secpreferred_lft85095secinet6fe80::5054:ff:fe00:5732/64scopelinkvalid_lftforeverpreferred_lftforever3:eth1:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscpfifo_faststateUPqlen1000link/ether08:00:27:7b:0f:b1brdff:ff:ff:ff:ff:ffinet172.17.8.101/24brd172.17.8.255scopeglobaleth1valid_lftforeverpreferred_lftforever4:eth2:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscpfifo_faststateUPqlen1000link/ether08:00:27:ef:25:06brdff:ff:ff:ff:ff:ffinet172.30.113.231/21brd172.30.119.255scopeglobaldynamiceth2valid_lft85096secpreferred_lft85096secinet6fe80::a00:27ff:feef:2506/64scopelinkvalid_lftforeverpreferred_lftforever5:docker0:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscnoqueuestateUPlink/ether02:42:d0:ae:80:eabrdff:ff:ff:ff:ff:ffinet172.33.68.1/24scopeglobaldocker0valid_lftforeverpreferred_lftforeverinet6fe80::42:d0ff:feae:80ea/64scopelinkvalid_lftforeverpreferred_lftforever7:veth295bef2@if6:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscnoqueuemasterdocker0stateUPlink/ether6a:72:d7:9f:29:19brdff:ff:ff:ff:ff:fflink-netnsid0inet6fe80::6872:d7ff:fe9f:2919/64scopelinkvalid_lftforeverpreferred_lftforever
[root@node1 ~]# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a37407a234dd docker.io/coredns/coredns@sha256:adf2e5b4504ef9ffa43f16010bd064273338759e92f6f616dd159115748799bc "/coredns -conf /etc/" About an hour ago Up About an hour k8s_coredns_coredns-5984fb8cbb-sjqv9_kube-system_c5a2e959-082a-11e8-b4cd-525400005732_0
944d4aa660e3 docker.io/openshift/origin-pod "/usr/bin/pod" About an hour ago Up About an hour k8s_POD_coredns-5984fb8cbb-sjqv9_kube-system_c5a2e959-082a-11e8-b4cd-525400005732_0
[root@node1 ~]# traceroute 172.33.96.3tracerouteto172.33.96.3 (172.33.96.3), 30 hops max, 60 byte packets1172.30.118.65 (172.30.118.65) 0.518 ms 0.367 ms 0.398 ms2172.33.96.3 (172.33.96.3) 0.451 ms 0.352 ms 0.223 ms
我们看到路由直接经过node3的公网IP后就到达了node3节点上的Pod。
Node1的iptables信息:
[root@node1 ~]# iptables -LChainINPUT (policy ACCEPT)targetprotoptsourcedestinationKUBE-FIREWALLall--anywhereanywhereKUBE-SERVICESall--anywhereanywhere/*kubernetesserviceportals*/ChainFORWARD (policy ACCEPT)targetprotoptsourcedestinationKUBE-FORWARDall--anywhereanywhere/*kubernetesforwardrules*/DOCKER-ISOLATIONall--anywhereanywhereDOCKERall--anywhereanywhereACCEPTall--anywhereanywherectstateRELATED,ESTABLISHEDACCEPTall--anywhereanywhereACCEPTall--anywhereanywhereChainOUTPUT (policy ACCEPT)targetprotoptsourcedestinationKUBE-FIREWALLall--anywhereanywhereKUBE-SERVICESall--anywhereanywhere/*kubernetesserviceportals*/ChainDOCKER (1 references)targetprotoptsourcedestinationChainDOCKER-ISOLATION (1 references)targetprotoptsourcedestinationRETURNall--anywhereanywhereChainKUBE-FIREWALL (2 references)targetprotoptsourcedestinationDROP all -- anywhere anywhere /* kubernetes firewall for dropping marked packets */ mark match 0x8000/0x8000
ChainKUBE-FORWARD (1 references)targetprotoptsourcedestinationACCEPT all -- anywhere anywhere /* kubernetes forwarding rules */ mark match 0x4000/0x4000
ACCEPT all -- 10.254.0.0/16 anywhere /* kubernetes forwarding conntrack pod source rule */ ctstate RELATED,ESTABLISHED
ACCEPT all -- anywhere 10.254.0.0/16 /* kubernetes forwarding conntrack pod destination rule */ ctstate RELATED,ESTABLISHED
ChainKUBE-SERVICES (2 references)targetprotoptsourcedestination