K8S输入 kubectl get nodes显示The connection to the server localhost:8080 was refused - did you specify the right host or port?
输入 kubectl get nodes
显示
The connection to the server localhost:8080 was refused - did you specify the right host or port?
出现这个问题的原因是 kubectl 命令需要使用 kubernetes-admin 来运行。可能是系统环境不干净导致,例如重装 k8s 前未完全清空配置等。
解决方法:
设置环境变量并更新
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
source ~/.bash_profile