kubectl get pods The connection to the server localhost:8080 was refused

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

原因:kubectl命令需要使用kubernetes-admin来运行。

解决办法:

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

2.配置环境变量
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile

   3.立即生效

source ~/.bash_profile


原文地址:https://www.cnblogs.com/peteremperor/p/12745004.html