解决Docker Unable to connect to the server: EOF
问题描述$ kubectl get pod -n istio-systemUnable to connect to the server: EOF问题原因分析我看了下我的host文件,在安装了k8s后自动增加了一条对kubernetes.docker.internal的地址解析。cat /etc/hosts# Added by Docker Desktop# To allow the same k
·
问题描述
$ kubectl get pod -n istio-system
Unable to connect to the server: EOF
问题原因分析
我看了下我的host文件,在安装了k8s后自动增加了一条对kubernetes.docker.internal
的地址解析。
cat /etc/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
然后我又使用了proxy,于是猜测由于proxy的问题导致走DNS解析去了,于是本地解析配置未生效。这也能浪费大半天时间,挺秃然。
解决方法一
直接终端执行,在当前终端生效:
export no_proxy=kubernetes.docker.internal,docker-for-desktop,$no_proxy
解决方法二
为了避免每次修改的麻烦,通过修改终端配置文件,将下面命令追加到文件末尾,以后每次打开terminal将自动生效:
export no_proxy=kubernetes.docker.internal,docker-for-desktop,$no_proxy # 拼接 no_proxy,防止被覆盖导致部分设置不生效
比如,我使用zsh,就修改:~/.zshrc
解决方法三——针对自定义 DNS
修改 proxy 软件的 hosts 配置,将 kubernetes.docker.internal 解析到本地。
举例:
-
针对 Clash X
1.编辑~/.config/clash/proxyIgnoreList.plist(如果没有该文件,则新建)
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <array> <string>192.168.0.0/16</string> <string>10.0.0.0/8</string> <string>172.16.0.0/12</string> <string>127.0.0.1</string> <string>localhost</string> <string>*.local</string> <!-- 上面的不能删掉 --> <!-- ...加入新的域名,如: --> <string>kubernetes.docker.internal</string> <string>*.baidu.com</string> </array> </plist>
2.重启 Clash X
更多推荐
所有评论(0)