【问题标题】:How to troubleshoot kubectl connectivity issue on GKE如何解决 GKE 上的 kubectl 连接问题
【发布时间】:2020-07-30 16:19:53
【问题描述】:

我们在 GKE 上有几个 K8S 集群。突然,生产集群无法通过kubectl 提供给我们(意味着它因超时错误而失败)。
我检查了集群的 K8S API,一切似乎都在工作,我可以在云 shell 中使用集群(通过主节点的相同 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

【问题讨论】:

  • 有升级吗?控制平面有时会变得不可用。
  • 我不这么认为。通知显示“节点升级可用”已有一段时间了。此外,正如我所说,CP 可从云外壳中获得。只是来自我的本地计算机的连接被阻止。集群中还有其他一些连接问题(某些 pod 的活跃度失败,但不是全部):confused:

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


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

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

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

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

    【讨论】:

      猜你喜欢
      • 2018-08-02
      • 1970-01-01
      • 2011-06-21
      • 2019-07-07
      • 2019-07-16
      • 2013-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多