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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM