k8s集群报错:The connection to the server localhost:8080 was refused - did you specify the right host or port?

root@k8s-master:~# kubectl get node
The connection to the server localhost:8080 was refused - did you specify the right host or port?

 

原因:使用kubeadm安装的k8s集群的/etc/kubernetes/admin.conf 为设置环境变量

 

解决方法设置环境变量并设置系统启动生效,并设置立即生效:

root@k8s-master:~# echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
root@k8s-master:~# source ~/.bash_profile

 

posted @ 2021-03-17 21:06  忙碌在路上  阅读(740)  评论(0编辑  收藏  举报