如何解决GKE上的kubectl连接问题

时间:2020-07-30 16:19:53

标签: kubernetes google-cloud-platform google-kubernetes-engine google-cloud-networking

我们在GKE上有几个K8S集群。突然,生产集群无法通过kubectl对我们进行保护(这意味着它因超时错误而失败)。
我检查了群集的K8S API,似乎一切正常,并且可以在云外壳中使用群集(通过主节点的相同IP)。
我还从本地计算机扫描了443端口,它显示filtered。但我不确定根本原因是什么。
我还检查了防火墙规则,没有deny阻止了它。
我还需要检查什么?

更新1
我为两个集群端点运行了tcptraceroute。响应kubectl的命令经过20跳后到达目的地。但是上述群集的结果失败:

❯ sudo tcptraceroute <Master Node IP> 443
Selected device en0, address 192.168.1.238, port 50617 for outgoing packets
Tracing the path to <Master Node IP> on TCP port 443 (https), 30 hops max
 1  192.168.1.1  3.527 ms  2.436 ms  2.578 ms
 2  some ip  17.407 ms  17.644 ms  18.379 ms
 3  some ip  17.172 ms  17.487 ms  17.676 ms
 4  some ip  17.173 ms  17.258 ms  17.292 ms
 5  some ip  30.990 ms  30.630 ms  30.745 ms
 6  108.170.241.236  31.337 ms  31.384 ms  32.783 ms
 7  209.85.254.49  31.290 ms  31.320 ms  278.574 ms
 8  142.250.227.193  35.582 ms  39.082 ms  84.725 ms
 9  209.85.142.95  41.474 ms * 614.860 ms
10  108.170.231.173  38.148 ms  36.335 ms  35.805 ms
11  * * * # this should be 72.14.234.27
...
20  * * * # this must have ended here at <some ip>.bc.googleusercontent.com
...
30  * * *
Destination not reached

2 个答案:

答案 0 :(得分:0)

因此有一个名为Master Authorized Networks的功能,如果启用,它将阻止来自非授权网络的连接。

答案 1 :(得分:0)

您可以使用SSH直接连接到节点并使用toolbox

使用命令 apt-get install iputils-ping 安装ping库,并使用命令 apt-get install tr​​aceroute 安装traceroute库,以验证与本地IP的节点。

此外,您还可以使用命令 kubectl exec -it pod-name-/ bin / bash 连接到特定的Pod,并为该节点安装相同的库,以运行连接测试

另一方面,如here所述,存在三种配置组合来控制对集群端点的访问,并选择最能满足您的需求。