Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes failed to discover supported resources: getsockopt: connection refused

I am going through the kubernetes tutorial at Udacity. When i run the the nginx image using the following command

kubectl run nginx --image=nginx:1.10.0

It given me the error

error: failed to discover supported resources: Get http://localhost:8080/apis/extensions/v1beta1: dial tcp 127.0.0.1:8080: getsockopt: connection refused

If i try to get pods using the following command

kubectl get pods

it says

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

The nginx server is running, i can tell because i can get the appropriate output by running curl http://127.0.0.1

I am not able to figure out what the issue is, and there are not a lot of resources on the internet for this problem. Can anyone please tell me how do i resolve it?

like image 644
sid0972 Avatar asked Jun 27 '18 16:06

sid0972


1 Answers

This issue often occurs when kubectl can not find the configuration credential for the intended cluster.

Check $HOME/.kube/config for cluster configuration. If configuration is empty or configuration is set for a wrong cluster, regenerate configuration by running,

gcloud container clusters get-credentials <CLUSTER_NAME> --zone <ZONE>

This will update the configuration credential in $HOME/.kube/config.

Now, everything should work as expected.

Reference: https://github.com/googlecodelabs/feedback/issues/537

like image 68
Shakil Avatar answered Sep 20 '22 16:09

Shakil