kubectl命令出现【The connection to the server localhost:8080 was refused

【The connection to the server localhost:8080 was refused - did you specify the right host or port?】

[root@k8s-master-1 kubernetes]# kubectl run snow --image=nginx:1.8
The connection to the server localhost:8080 was refused - did you specify the right host or port?

解决方法:
cp -i admin.conf /root/.kube/config

[root@k8s-master-1 ~]# cp -i /etc/kubernetes/admin.conf ./.kube/config

[root@k8s-master-1 ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx-1-6664c49886-56vqs 1/1 Running 0 17h
nginx-deployment-7848d4b86f-d5s2w 1/1 Running 1 20h
nginx-deployment-7848d4b86f-h8cnr 1/1 Running 1 20h

原文地址:https://www.cnblogs.com/yyuuee/p/14479654.html