Kubernetes 世纪7号的库伯内特斯在流浪者中无法访问ClusterIP
环境Kubernetes 世纪7号的库伯内特斯在流浪者中无法访问ClusterIP,kubernetes,Kubernetes,环境 Linux Version: Linux k8smaster 3.10.0-514.2.2.el7.x86_64 #1 SMP Tue Dec 6 23:06:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux Vagrant Version: Installed Version: 1.9.1 Kubernetes Version: 1.5.2 Flannel Version: 0.7.0 Kubernetes集群 我使用vagrant创建了三个C
Linux Version: Linux k8smaster 3.10.0-514.2.2.el7.x86_64 #1 SMP Tue Dec 6 23:06:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Vagrant Version: Installed Version: 1.9.1
Kubernetes Version: 1.5.2
Flannel Version: 0.7.0
Kubernetes集群
我使用vagrant创建了三个Centos虚拟机并指定了专用ip。(eth0是默认的nat网络)
使用yum-Install安装kubernetes
On master: yum install kubernetes-master
On node: yum install kubernetes-node
配置群集以使群集可用
[root@k8smaster ~]# kubectl get nodes
NAME STATUS AGE
node01 Ready 1d
node02 Ready 1d
[root@k8smaster ~]# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
heapster-1765662453-rzlhp 1/1 Running 0 20h
kube-dns-4264603877-wd7nq 4/4 Running 4 23h
kubernetes-dashboard-2405669852-7svw7 1/1 Running 0 19h
monitoring-grafana-3730655072-4z3b8 1/1 Running 0 20h
monitoring-influxdb-957705310-tvcqr 1/1 Running 0 20h
现在,我将为TestClusterIP创建一个webapp
[root@k8smaster ~]# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE
webapp-61skd 1/1 Running 0 19h 10.1.27.3 node02
webapp-swqxg 1/1 Running 0 19h 10.1.21.5 node01
[root@k8smaster ~]# kubectl get svc
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes 10.254.0.1 <none> 443/TCP 1d
webapp 10.254.247.62 <none> 8081/TCP 18h
无法访问时:
The wireshark: 2081 3222.487736215 10.0.2.15 -> 10.1.27.3 TCP 60 57184 > http-alt [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=90394425 TSecr=0 WS=128
the access_log: (no context)
检查iptables
[root@node02 ~]# iptables -t nat -S |grep webapp
-A KUBE-SEP-GK5MEJWLZBFFJJ45 -s 10.1.21.5/32 -m comment --comment "default/webapp:" -j KUBE-MARK-MASQ
-A KUBE-SEP-GK5MEJWLZBFFJJ45 -p tcp -m comment --comment "default/webapp:" -m tcp -j DNAT --to-destination 10.1.21.5:8080
-A KUBE-SEP-V6PLSL5CQOUVXPSD -s 10.1.27.3/32 -m comment --comment "default/webapp:" -j KUBE-MARK-MASQ
-A KUBE-SEP-V6PLSL5CQOUVXPSD -p tcp -m comment --comment "default/webapp:" -m tcp -j DNAT --to-destination 10.1.27.3:8080
-A KUBE-SERVICES -d 10.254.247.62/32 -p tcp -m comment --comment "default/webapp: cluster IP" -m tcp --dport 8081 -j KUBE-SVC-BL7FHTIPVYJBLWZN
-A KUBE-SVC-BL7FHTIPVYJBLWZN -m comment --comment "default/webapp:" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-GK5MEJWLZBFFJJ45
-A KUBE-SVC-BL7FHTIPVYJBLWZN -m comment --comment "default/webapp:" -j KUBE-SEP-V6PLSL5CQOUVXPSD
这似乎很正常
我真的不知道发生了什么,这让我头疼!!!有谁能给我一个好的解决方案吗?凯文,这个问题看起来更像是路线问题。尝试运行以下命令,看看是否有帮助
sudo route add <kubernetes-clusterip> gw <kube-master-ip>
sudo路线添加gw
在你的仆从身上。Uday,谢谢你回答我的问题。我按照你说的做了,但是没有用。只需将10.0.2.15(我的节点eth0 ip地址)转换为192.168.1.x(我的节点eth1 ip地址) 你可以看到我的路线表
[root@node01 kubernetes]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.2.2 0.0.0.0 UG 100 0 0 eth0
10.0.2.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
10.1.0.0 0.0.0.0 255.255.0.0 U 0 0 0 flannel0
10.1.21.0 0.0.0.0 255.255.255.0 U 0 0 0 docker0
10.254.5.182 192.168.1.100 255.255.255.255 UGH 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
好的,当我添加下面的路由列表时,它工作了,但我不知道为什么,我添加了一个导出到flannel0的路由,不工作
route add ClusterIP dev docker0
不是所有的包都是法兰式的吗?Uday,谢谢你回答我的问题。我按照你说的做了,但是,它不起作用。只需将10.0.2.15(我的节点eth0 ip地址)转换成192.168.1.x(我的节点eth1 ip地址),你可以看到我的路由表。好的,当我添加以下路由列表时,它起作用,但我不知道为什么,我已经添加了一条出口到法兰布的路线,不工作!!!
[root@node01 kubernetes]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.2.2 0.0.0.0 UG 100 0 0 eth0
10.0.2.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
10.1.0.0 0.0.0.0 255.255.0.0 U 0 0 0 flannel0
10.1.21.0 0.0.0.0 255.255.255.0 U 0 0 0 docker0
10.254.5.182 192.168.1.100 255.255.255.255 UGH 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
route add ClusterIP dev docker0