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

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

环境变量

原因:kubernetes master没有与本机绑定,集群初始化的时候没有绑定,此时设置在本机的环境变量即可解决问题。

解决方式

步骤一:设置环境变量

具体根据情况,此处记录linux设置该环境变量
方式一:编辑文件设置
	   vim /etc/profile
	   在底部增加新的环境变量 export KUBECONFIG=/etc/kubernetes/admin.conf
方式二:直接追加文件内容
	echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> /etc/profile

步骤二:使生效

source /etc/profile

解决问题后截图:

sudo kubectl get pods -n kube-system

 

 

 

https://blog.csdn.net/CEVERY/article/details/108753379

 

posted @ 2021-11-15 12:16  西瓜君~  阅读(5753)  评论(0编辑  收藏  举报