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

在Kubernetes的node节点上运行kubectl命令出现了如下错误:The connection to the server localhost:8080 was refused - did you specify the right host or port?

出现这个问题的原因是kubectl命令需要使用kubernetes-admin来运行。

解决方法如下:

将master节点中的/etc/kubernetes/admin.conf文件拷贝到node节点的相同目录下

[root@kmaster kubernetes]# scp admin.conf 192.168.126.114:/etc/kubernetes/

然后配置环境变量并使之生效

[root@knode3 ~]# echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
[root@knode3 ~]# source ~/.bash_profile

接着再运行kubectl命令就OK了

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

上一篇:9.22mysql学习


下一篇:Eclipse中屏蔽日志