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

执行kubectl get pods报错如下所示:

kubectl get pods -n kube-system
The connection to the server localhost:8080 was refused - did you specify the right host or port?

解决方法:

vim /etc/profile
export KUBECONFIG=/etc/kubernetes/admin.conf

激活环境变量

source /etc/profile

再次执行kubectl get pods,成功执行如下所示


kubectl get pods -n kube-system
NAME                               READY   STATUS    RESTARTS   AGE
coredns-6d8c4cb4d-grzcs            0/1     Pending   0          12m
coredns-6d8c4cb4d-mn6jr            0/1     Pending   0          12m
etcd-bigdata1                      1/1     Running   7          13m
kube-apiserver-bigdata1            1/1     Running   103        13m
kube-controller-manager-bigdata1   1/1     Running   5          13m
kube-proxy-6b7p5                   1/1     Running   0          12m
kube-scheduler-bigdata1            1/1     Running   5          13m
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐