k8s kubectl the server localhost:8080 was refused

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/educast/article/details/89849579

次时使用kubectl命令会提示错误

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

解决办法:

对于非root用户
 mkdir -p $HOME/.kube
 sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
 sudo chown $(id -u):$(id -g) $HOME/.kube/config

 对于root用户
 export KUBECONFIG=/etc/kubernetes/admin.conf
 也可以直接放到~/.bash_profile
 echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile

猜你喜欢

转载自blog.csdn.net/educast/article/details/89849579