kubectl get nodes` returns `The connection to the server 10.xxxxxxxxx was refused

10/25/2018

kubectl get pods -o wide --all-namespaces

it gives kubectl get nodes returns 'The connection to the server 10.xxxxxxxxx was refused. did you specify right host or port?'

kindly do guide.

thanks

-- user10478566
google-kubernetes-engine
kubectl
kubernetes

1 Answer

10/25/2018

It seems your kubeconfig is not correct after doing kubeadm init, you didnt do the below steps.

Your Kubernetes master has initialized successfully!
To start using your cluster, you need to run (as a regular user):
sudo cp /etc/kubernetes/admin.conf $HOME/
sudo chown $(id -u):$(id -g) $HOME/admin.conf
export KUBECONFIG=$HOME/admin.conf

Try it and check

If you are on GKE try doing below steps to autogenerate kubeconfig

gcloud container clusters get-credentials "CLUSTER NAME"
-- Shashank Pai
Source: StackOverflow