Kubernetes failed to discover supported resources: getsockopt: connection refused

6/27/2018

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?

-- sid0972
docker
google-kubernetes-engine
kubernetes

6 Answers

4/25/2019

In some cases, it is simply because you need the kubectl run command as root (e.g. sudo it).

-- Farshid
Source: StackOverflow

8/25/2019

You need to set up the zone first:

gcloud config set compute/zone us-central1-b

then add a cluster there :

gcloud container clusters create io

now you can run the commands . Let me know if found a problem there :)

-- vansh Kapoor
Source: StackOverflow

4/4/2019

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

-- Shakil
Source: StackOverflow

6/27/2018

Check your kubectl config file (~/.kube/config)

For testing purposes, you can use the admin one:

kubectl --kubeconfig /etc/kubernetes/admin.conf get po

Or (again, for testing)

sudo cp /etc/kubernetes/admin.conf $HOME/
sudo chown $(id -u):$(id -g) $HOME/admin.conf
export KUBECONFIG=$HOME/admin.conf

You can see more suggestions in kubernetes/kubernetes issue 23726

As commented below, that requires kubernetes to be installed, for the node to be able to join a cluster:

sudo kubeadm join --token TOKEN MASTER_IP:6443
-- VonC
Source: StackOverflow

4/29/2019

failed to discover supported resources ......

kubectl command line tools connects with kube-apiserver at port 8443 for its operations.

To proble whether the apiserver is up, try curl https://192.168.99.100:8443

If it fails, it means kube-apiserver is not running. Most probably minikube would not be running.

So try:

  1. minikube status

    minikube start

OR

  1. restart the VM
-- Muralidharan.rade
Source: StackOverflow

6/28/2018

The solution was simple, as @VonC suggested, i did not have kubernetes installed, i followed this tutorial, and now i can proceed with my work.

-- sid0972
Source: StackOverflow