error: failed to discover supported resources: Get http://localhost:8080/apis/apps/v1?

12/21/2020

I am new to Kubernetes and I am trying to create a pod but I am facing this error can someone help?

(base) Dishas-Air:config dishaaa$ kubectl create deployment nanopore --image=nginx

W1221 16:55:10.854937   48732 loader.go:223] Config not found: /etc/kubernetes/kubelet.conf
W1221 16:55:10.887246   48732 loader.go:223] Config not found: /etc/kubernetes/kubelet.conf
error: failed to discover supported resources: Get http://localhost:8080/apis/apps/v1?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
-- DISHA98 LODHA
kubernetes

1 Answer

12/22/2020

It seems that your cluster was not initialized correctly or you did not went thru all the prerequisites config to make work appropriately or your cluster simply is not running.

The first step would be to check your (~/.kube/config) file and if it exist. The kubectl command-line tool uses kubeconfig files to find the information it needs to choose a cluster and communicate with the API server of a cluster. By default, it looks for a file named config in the $HOME/.kube directory.

Kubeadm once initialize your control plane ask you to perform couple of commands in order to start using your cluster. This is need to make kubectl work for your non-root user:

Your Kubernetes control-plane has initialized successfully!
To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

The above information is place assuming you went all the steps up to init. If you have not please have a look at creating kubeadm cluster document.

If you are using minikube please have look if you cluster is running by minikube status. If your Kubernetes cluster is not running please go thru minikube get started document.

-- acid_fuji
Source: StackOverflow