K8s - X - 3 The connection to the server localhost:8080 was refused - did you specif...
一、kubernetes The connection to the server localhost:8080 was refused - did you specif…
1. 问题描述
执行 kubectl 时(如:kubectl get pod
),提示一下问题:
The connection to the server localhost:8080 was refused - did you specify the right host or port?
说明:
出现这个问题的原因是 kubectl 命令需要使用 kubernetes-admin 来运行。可能是系统环境不干净导致,例如重装 k8s 前未完全清空配置等。
2. 解决方案
2.1 设置环境变量并更新
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
source ~/.bash_profile