sudo kubectl get nodes - The connection to the server localhost:8080 was refused

10/6/2021

Following this documentation I was able to setup a master node and three worker nodes. However, when I run the command sudo kubectl get nodes after being able to SSH to the master node, I get the following error:

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

I also checked /etc/kubernetes/admin.conf for admin.conf file if that was causing the error, the file does not exist. In fact, I couldn't find the /kubernets directory inside /etc directory. Why is there no kubernetes/admin.conf folder and file in the first place and how can I solve this issue? Or am I looking at wrong etc directory?

-- Sebastian
kubectl
kubernetes

1 Answer

10/7/2021

I solved this issue. Even though the error was with regard to connection refusal, the actual issue was with resource allocation. I noticed that the worker nodes have actually failed to launch. So I went back and edited the cluster-settings.tfvars file and allocated 2046 MiB of memory to each node as it is specified in Kubernetes official documentation. Hope this will help anyone who runs into similar issue to mine.

-- Sebastian
Source: StackOverflow