Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coredns in pending state in Kubernetes cluster

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?

like image 965
Aditya Datta Avatar asked Oct 02 '18 13:10

Aditya Datta


People also ask

How does CoreDNS work in Kubernetes?

About CoreDNS Like Kubernetes, the CoreDNS project is hosted by the CNCF. You can use CoreDNS instead of kube-dns in your cluster by replacing kube-dns in an existing deployment, or by using tools like kubeadm that will deploy and upgrade the cluster for you.

What is pending status in Kubernetes?

If a Pod is stuck in Pending it means that it can not be scheduled onto a node. Generally this is because there are insufficient resources of one type or another that prevent scheduling.

Is CoreDNS default in Kubernetes?

In Kubernetes version 1.11 and later, CoreDNS is recommended and is installed by default with kubeadm. For more information on how to configure CoreDNS for a Kubernetes cluster, see the Customizing DNS Service.


2 Answers

Try to install Pod network add-on (Base on this guide).

Run this line:

kubectl apply -f https://docs.projectcalico.org/v3.14/manifests/calico.yaml
like image 122
Ben Even Tsur Avatar answered Oct 17 '22 16:10

Ben Even Tsur


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.

like image 3
Artem Golenyaev Avatar answered Oct 17 '22 14:10

Artem Golenyaev