docker desktop k8s错误Unable to connect to the server: EOF
问题
当使用 Docker Desktop 开启 Kubernetes 之后,在终端执行命令 kubectl get nodes 时,出现以下错误:
Unable to connect to the server: EOF
根因分析
终端执行命令 kubectl cluster-info,输出如下:
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
error: Get "https://kubernetes.docker.internal:6443/api?timeout=32s": net/http: TLS handshake timeout - error from a previous attempt: EOF
说明现在没法访问到 kubernetes.docker.internal,查看一下本机 hosts 文件发现新增了以下配置:
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
这个时候问题就显而易见了,由于我本机 Shell 使用了 proxy 配置,而代理没有忽略 Docker 的这个特殊域名。
解决方案
将 kubernetes.docker.internal 添加到 NO_PROXY 环境变量中。


文完撒花🎉!感谢观看👏!

开启 Docker Desktop 的 Kubernetes 功能后运行正常,但在终端中使用 `kubectl` 命令依然会报错,这是什么原因呢...
浙公网安备 33010602011771号