如何修复 kubectl Unable to connect to the server: dial tcp ...:443: i/o timeout
问题:
你想创建或编辑 Kubernetes 服务,但运行例如
kubectl-create-my-service.sh
kubectl create -f my-service.yml你看到类似这样的错误消息:
kubectl-timeout-error.txt
Unable to connect to the server: dial tcp 35.198.129.60:443: i/o timeout解决方案
此问题有三个常见原因:
- 你的 Kubernetes 集群未运行。验证你的集群是否已启动,例如通过 ping IP 地址。
- 存在阻止你访问集群的网络问题。验证你可以 ping IP 并尝试排查是否有防火墙阻止访问
- 你配置的集群已不存在。
对于 Google Cloud Kubernetes,情况 (3) 可以通过配置 Kubernetes 使用你当前的集群轻松修复:
gcloud-get-credentials.sh
gcloud container clusters get-credentials [cluster name] --zone [zone]这将自动更新 kubectl 的默认集群。
如果你不知道正确的集群名称和区域,使用
gcloud-list-clusters.sh
gcloud container clusters listCheck out similar posts by category:
Cloud, Container, Kubernetes
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow