Steps-to-resolve-CoreDNS-stuck-at-‘ContainerCreating-status-using-the-Flannel-network

The connection to the server localhost:8080 was refused

Posted by

Are you concerned about to Resolve CoreDNS stuck at ContainerCreating? In this blog, we will walk you through the steps to Resolve the CoreDNS POD related issue using a flannel network.

INFRASTRUCTURE OVERVIEW

  • Currently we have 2 node cluster in our testing environment as shown below.
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network – StackBill CMP
  • Also, we have installed the kubernetes in our test environment. You can follow below link to install kubernetes in your end.

https://blog.stackbill.com/2023/07/30/step-by-step-to-install-2-node-kubernetes-cluster-in-cloudstack-using-ubuntu-20-04/

  • After we completed the kubernetes installation, we check the nodes status and it shows “Not ready”.
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network – StackBill Cloud Management Portal
  • Also, you can find the coreDNS is in containercreating status using flannel network.
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network – StackBill Cloud Management Portal
  • Once you describe the coreDNS POD, you will get find the logs states that “plugin type=”flannel” failed (add): loadFlannelSubnetEnv failed: open /run/flannel/subnet.env: no such file or directory
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network – StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network – StackBill Cloud Management Portal

REASONS FOR THIS ERROR

  • While installing the kubernetes, we failed to specify the POD CIDR.
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network – StackBill Cloud Management Portal
  • The below is the actual syntax to initiate Kubernetes installation.

Syntax: kubeadm init –apiserver-advertise-address <eth0 address> –pod-network-cidr=<the CIDR address>
Example: kubeadm init –apiserver-advertise-address <eth0 address> –pod-network-cidr=10.244.0.0/16

  • In our test environment, we use flannel network, which use the default POD CIDR value is 10.244.0.0/16. We failed to specify this CIDR range while initiated kubernetes installation.
  • In you specified the POD CIDR correctly, subnet.env file will be created automatically under /run/flannel/ folder.
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network – StackBill Cloud Management Portal
  • Currently there is no file is available under this folder.

TROUBLESHOOTING STEPS

  • First, reset the kubernetes using kubeadm reset command.
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network – StackBill Cloud Management Portal
  • It will shows the warning before Kubernetes reset. Type Y and press enter.
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network – StackBill Cloud Management Portal
  • Kubernetes reset has been completed successfully.
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network – StackBill Cloud Management Portal
  • Now, try to re-initiate the kubernetes install using below syntax.
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network – StackBill Cloud Management Portal

Syntax: kubeadm init –apiserver-advertise-address <eth0 address> –pod-network-cidr=<the CIDR address>
Example: kubeadm init –apiserver-advertise-address <eth0 address> –pod-network-cidr=10.244.0.0/16
 

  • Kubernetes has been initiated successfully.
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network – StackBill Cloud Management Portal
  • Now apply the flannel network configuration using below command.
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network – StackBill Cloud Management Portal

kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml

  • Now try to list the nodes, you can able to see the master node is in Ready status.
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network – StackBill Cloud Management Portal
  • Also, you can verify the kube-system and make sure that all the POD’s are in running state.

Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal

  • You can also verify the /run/flannel/ folder and you will able to find subnet.env file.
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network – StackBill Cloud Management Portal
  • You can able to find the POD network CIDR inside subnet.env file.
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network – StackBill Cloud Management Portal
  • Also, you can find the kubernetes cluster information using the below command.
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network - StackBill Cloud Management Portal
Steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network – StackBill Cloud Management Portal

kubectl -n kube-system get cm kubeadm-config -o yaml

Thanks for reading this blog. We hope you gained a useful information and steps to Resolve CoreDNS stuck at ContainerCreating using the Flannel network.

Next Topic: How to Create Linux OS Templates with KVM on Ubuntu 20.04?

 

Leave a Reply

Your email address will not be published. Required fields are marked *