Kubernetes: nodePort 在所有 nodeIP 上都没有响应

创建于 2017-02-28  ·  1评论  ·  资料来源: kubernetes/kubernetes

Kubernetes 版本
客户端版本:version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"08e099554f3c31f6e6f07b448ab3ed78d05205​​07", GitTreeState:"clean", BuildDate:"2017-01-12T04:57: 25Z”,GoVersion:“go1.7.4”,编译器:“gc”,平台:“darwin/amd64”}
服务器版本:version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.3", GitCommit:"029c3a408176b55c30846f0faedf56aae5992e9b", GitTreeState:"clean", BuildDate:"2017-02-15T06:34: 56Z”,GoVersion:“go1.7.4”,编译器:“gc”,平台:“linux/amd64”}

master 和 minions 上的 Docker 版本
$码头工人-v
Docker 版本 1.13.1,构建 092cba3

环境

  • 内核(例如uname -a ):
    Linux knode-master 4.4.0-45-generic #66-Ubuntu SMP 2016 年 10 月 19 日星期三 14:12:37 UTC x86_64 x86_64 x86_64 GNU/Linux
  • 安装工具
    kubeadm

  • 其他

发生了什么
使用kubeadm页面我安装了一个三节点集群。

$ kc describe nodes | awk '/Addresses/ {print $2}' | awk -F',' '{print $3}' 
knode-0
knode-1
knode-master

安装的运河豆荚网络:

kubectl create -f https://raw.githubusercontent.com/tigera/canal/master/k8sinstall/kubeadm/canal.yaml

此时节点、服务、pod 是健康的。 于是进入仪表板

kubectl create -f https://rawgit.com/kubernetes/dashboard/master/src/deploy/kubernetes-dashboard.yaml

$ kubectl get -n kube-system services
NAME                   CLUSTER-IP       EXTERNAL-IP   PORT(S)         AGE
canal-etcd             10.96.232.136    <none>        6666/TCP        5m
kube-dns               10.96.0.10       <none>        53/UDP,53/TCP   13h
kubernetes-dashboard   10.110.163.186   <nodes>       80:31699/TCP    1m

您期望发生的事情
服务文档中的nodePort 部分指示 nodePort 应该在所有 nodeIP 上可见。

就我而言,并非所有 nodeIP 都响应仪表板的 nodePort 31699 上的请求并将它们转发到仪表板 pod。
只有托管 pod 的节点(或 minion)似乎会响应浏览器请求。 其他节点(或 minions)没有响应。

如何重现它(尽可能最小和精确):

_来自knode-1(一个仆从):_

$ sudo docker ps -a | grep dashboard
79e23eff2c26        gcr.io/google_containers/kubernetes-dashboard-amd64:v1.5.1   "/dashboard --port..."   44 minutes ago      Up 43 minutes 

_curl 访问集群外的仪表板:_

到 _knode-0:31699 的连接超时

$ curl -m 2 -O http://knode-0:31699/#/workload?namespace=default
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0curl: (28) Connection timed out after 2003 milliseconds

从 knode-1:31699 下载成功

$ curl -m 2 -O http://knode-1:31699/#/workload?namespace=default
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   811  100   811    0     0  18097      0 --:--:-- --:--:-- --:--:-- 18431

*iptables *

_来自 knode-1(nodePort 31699 可访问):_

$ sudo iptables-save | grep dashboard
-A KUBE-NODEPORTS -p tcp -m comment --comment "kube-system/kubernetes-dashboard:" -m tcp --dport 31699 -j KUBE-MARK-MASQ
-A KUBE-NODEPORTS -p tcp -m comment --comment "kube-system/kubernetes-dashboard:" -m tcp --dport 31699 -j KUBE-SVC-XGLOHA7QRQ3V22RZ
-A KUBE-SEP-4CN2KLL64AIMJOUC -s 192.168.92.6/32 -m comment --comment "kube-system/kubernetes-dashboard:" -j KUBE-MARK-MASQ
-A KUBE-SEP-4CN2KLL64AIMJOUC -p tcp -m comment --comment "kube-system/kubernetes-dashboard:" -m tcp -j DNAT --to-destination 192.168.92.6:9090
-A KUBE-SERVICES -d 10.110.163.186/32 -p tcp -m comment --comment "kube-system/kubernetes-dashboard: cluster IP" -m tcp --dport 80 -j KUBE-SVC-XGLOHA7QRQ3V22RZ
-A KUBE-SVC-XGLOHA7QRQ3V22RZ -m comment --comment "kube-system/kubernetes-dashboard:" -j KUBE-SEP-4CN2KLL64AIMJOUC

_来自 knode-0 (nodePort 31699 不可访问):_

$ sudo iptables-save | grep dashboard
-A KUBE-NODEPORTS -p tcp -m comment --comment "kube-system/kubernetes-dashboard:" -m tcp --dport 31699 -j KUBE-MARK-MASQ
-A KUBE-NODEPORTS -p tcp -m comment --comment "kube-system/kubernetes-dashboard:" -m tcp --dport 31699 -j KUBE-SVC-XGLOHA7QRQ3V22RZ
-A KUBE-SEP-4CN2KLL64AIMJOUC -s 192.168.92.6/32 -m comment --comment "kube-system/kubernetes-dashboard:" -j KUBE-MARK-MASQ
-A KUBE-SEP-4CN2KLL64AIMJOUC -p tcp -m comment --comment "kube-system/kubernetes-dashboard:" -m tcp -j DNAT --to-destination 192.168.92.6:9090
-A KUBE-SERVICES -d 10.110.163.186/32 -p tcp -m comment --comment "kube-system/kubernetes-dashboard: cluster IP" -m tcp --dport 80 -j KUBE-SVC-XGLOHA7QRQ3V22RZ
-A KUBE-SVC-XGLOHA7QRQ3V22RZ -m comment --comment "kube-system/kubernetes-dashboard:" -j KUBE-SEP-4CN2KLL64AIMJOUC

我们需要知道的其他任何事情

在 RHEL 7.3 上可以重现相同的行为。

sinetwork

最有用的评论

我遇到了同样的问题。
运行iptables -P FORWARD ACCEPT可能会解决您的问题。 但不确定与 docker v1.13.1 集成时是否存在错误

>所有评论

我遇到了同样的问题。
运行iptables -P FORWARD ACCEPT可能会解决您的问题。 但不确定与 docker v1.13.1 集成时是否存在错误

此页面是否有帮助?
0 / 5 - 0 等级