我是靠谱客的博主 疯狂白开水,这篇文章主要介绍执行kubectl错误The connection to the server localhost:8080 was refused,现在分享给大家,希望可以做个参考。

今天在node上执行kubectl get pod结果出现报错

[root@cm-server ~]# kubectl get pod
The connection to the server localhost:8080 was refused - did you specify the right host or port?

查阅资料后才知道kubectl命令需要使用kubernetes-admin来运行,而node上并没有admin.conf文件。将master上的admin.conf文件拷贝到node,然后执行一下命令

[root@cm-server ~]# cd /etc/kubernetes/
[root@cm-server kubernetes]# ls
bootstrap-kubelet.conf
kubelet.conf
manifests
pki
[root@cm-server kubernetes]# echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
[root@cm-server kubernetes]# source ~/.bash_profile

再次执行kubectl get pod命令就可以使用了。

最后

以上就是疯狂白开水最近收集整理的关于执行kubectl错误The connection to the server localhost:8080 was refused的全部内容,更多相关执行kubectl错误The内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(117)

评论列表共有 0 条评论

立即
投稿
返回
顶部