How to restart a kubernetes-pod stuck in pending state?

12/20/2018

I'm setting up a Kubernetes master node. Just the master node, no worker nodes for now.

Set up was completed without any issues using this tutorial. Now,

$kubectl get pods -o wide --all-namespaces
kube-system   calico-kube-controllers-694687c474-96b7h   0/1     Pending   0          4h19m   <none>          <none>             <none>           <none>
kube-system   coredns-86c58d9df4-dv847                   0/1     Pending   0          4h28m   <none>          <none>             <none>           <none>
kube-system   coredns-86c58d9df4-pqvxv                   0/1     Pending   0          4h28m   <none>          <none>             <none>           <none>
kube-system   etcd-ip-172-31-40-128                      1/1     Running   0          4h28m   172.31.40.128   ip-172-31-40-128   <none>           <none>
kube-system   kube-apiserver-ip-172-31-40-128            1/1     Running   0          4h28m   172.31.40.128   ip-172-31-40-128   <none>           <none>
kube-system   kube-controller-manager-ip-172-31-40-128   1/1     Running   0          4h28m   172.31.40.128   ip-172-31-40-128   <none>           <none>
kube-system   kube-proxy-zvgcl                           1/1     Running   0          4h28m   172.31.40.128   ip-172-31-40-128   <none>           <none>
kube-system   kube-scheduler-ip-172-31-40-128            1/1     Running   0          4h27m   172.31.40.128   ip-172-31-40-128   <none>           <none>
kube-system   kubernetes-dashboard-57df4db6b-wlv86       0/1     Pending   0          3h55m   <none>          <none>    

When I try to open the Kubernetes-dashboard using, http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/ in local browser, it fails to open the dashboard and I receive below error in the browser:

{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {

  },
  "status": "Failure",
  "message": "no endpoints available for service \"kubernetes-dashboard\"",
  "reason": "ServiceUnavailable",
  "code": 503
}

I assume as the kubernetes-dashboard pod is pending, dashboard would not open. How do I get it to work for me?

Any help is appreciated.

-- Dhiraj
kubernetes-pod

1 Answer

12/20/2018

You can do kubectl describe pod kubernetes-dashboard-57df4db6b-wlv86 and the output should tell you why the Pod couldn't be scheduled. There can be different reasons and kubernetes 'debug pods' guide covers several of them. The most common is insufficient resources but it could be other things, especially on a new cluster. I notice the DNS pods are also pending - I'd suggest looking at those first as you need networking to run applications.

-- Ryan Dawson
Source: StackOverflow