k8s执行命令提示连接服务器was refuused

有时我们在服务器异常重启以后,部署在上面的k8s执行kubectl命令直接提示

The connection to the server 192.168.1.72:6443 was refused - did you specify the right host or port?

出现这种情况时我们可以先检查kubelet和docker服务的状态,有时我们重启可能需要等一下k8s服务拉起来

如果上述方式还不行,可以尝试重新声明下环境变量

ll /etc/kubernetes/admin.conf
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
source ~/.bash_profile

然后我们再使用kubectl执行命令,发现可以正常返回。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://sulao.cn/post/876.html

我要评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。