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