Coredns in pending state in Kubernetes cluster

Aditya Datta picture Aditya Datta · Oct 2, 2018 · Viewed 15k times · Source

I am trying to configure a 2 node Kubernetes cluster. First I am trying to configure the master node of the cluster on a CentOS VM. I have initialized the cluster using 'kubeadm init --apiserver-advertise-address=172.16.100.6 --pod-network-cidr=10.244.0.0/16' and deployed the flannel network to the cluster. But when I do 'kubectl get nodes', I get the following output ----

[root@kubernetus ~]# kubectl get nodes
NAME         STATUS     ROLES    AGE   VERSION
kubernetus   NotReady   master   57m   v1.12.0

Following is the output of 'kubectl get pods --all-namespaces -o wide ' ----

[root@kubernetus ~]# kubectl get pods --all-namespaces -o wide
NAMESPACE     NAME                                 READY   STATUS    RESTARTS   AGE   IP             NODE         NOMINATED NODE
kube-system   coredns-576cbf47c7-9x59x             0/1     Pending   0          58m   <none>         <none>       <none>
kube-system   coredns-576cbf47c7-l52wc             0/1     Pending   0          58m   <none>         <none>       <none>
kube-system   etcd-kubernetus                      1/1     Running   2          57m   172.16.100.6   kubernetus   <none>
kube-system   kube-apiserver-kubernetus            1/1     Running   2          57m   172.16.100.6   kubernetus   <none>
kube-system   kube-controller-manager-kubernetus   1/1     Running   1          57m   172.16.100.6   kubernetus   <none>
kube-system   kube-proxy-hr557                     1/1     Running   1          58m   172.16.100.6   kubernetus   <none>
kube-system   kube-scheduler-kubernetus            1/1     Running   1          57m   172.16.100.6   kubernetus   <none>

coredns is in a pending state for a very long time. I have removed docker and kubectl, kubeadm, kubelet a no of times & tried to recreate the cluster, but every time it shows the same output. Can anybody help me with this issue?

Answer

Artem Golenyaev picture Artem Golenyaev · Oct 3, 2018

Unable to update cni config: No networks found in /etc/cni/net.d ..... Oct 02 19:21:32 kubernetus kubelet[19007]: E1002 19:21:32.886170 19007 kubelet.go:2167] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized

According to this error, you forgot to initialize a Kubernetes Pod network add-on. Looking at your settings, I suppose it should be Flannel.

Here is the instruction from the official Kubernetes documentation:

For flannel to work correctly, you must pass --pod-network-cidr=10.244.0.0/16 to kubeadm init.

Set /proc/sys/net/bridge/bridge-nf-call-iptables to 1 by running sysctl net.bridge.bridge-nf-call-iptables=1 to pass bridged IPv4 traffic to iptables’ chains. This is a requirement for some CNI plugins to work, for more information please see here.

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.10.0/Documentation/kube-flannel.yml

Note that flannel works on amd64, arm, arm64 and ppc64le, but until flannel v0.11.0 is released you need to use the following manifest that supports all the architectures:

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/c5d10c8/Documentation/kube-flannel.yml

For more information, you can visit this link.