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

╄→尐↘猪︶ㄣ 提交于 2019-11-29 04:29:22
Hareesh R

Make a copy of the config file and resolve this issue:

sudo mkdir ~/.kube
sudo cp /etc/kubernetes/admin.conf ~/.kube/

cd ~/.kube

sudo mv admin.conf config
sudo service kubelet restart

you need to specify kubeconfig for kubectl like this.

kubectl --kubeconfig .kube/config  get nodes

kubectl consumes an interface exposed by a Container Service(GCP, ACS or AWS) When you receive that error it could be that you didn't configure the authentication to that Container Service(GCp, ACS, AWS, or etc) For example in Google Container Service you can do: gcloud auth login

Finally

gcloud container clusters get-credentials [cluster-name] --zone cluster-zone
[cluster-zone]

There will be an output like this one:

Fetching cluster endpoint and auth data.
kubeconfig entry generated for website.

The last line is what we were searching for

The problem is that the connection defaults to localhost:8080, just change kubectl.cfg specifying where you desire it to connect to. Another possible problem is the path to it not being set correctly, in the variable KUBECONFIG. Good luck

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!