Kube-Router is stuck in CrashLoopBackoff

Viewed 480

When installing Kube-router on a single node Kubernetes Cluster, I came across the following issue:

kube-system   kube-router-wnnq8                          0/1     CrashLoopBackOff   11         55m

Output of the logs:

kubectl logs kube-router-wnnq8 -n kube-system
I0826 06:02:25.760806       1 kube-router.go:223] Running /usr/local/bin/kube-router version v1.0.1, built on 2020-07-28T23:51:21+0000, go1.10.8
Failed to parse kube-router config: Failed to build configuration from CLI: Error loading config file "/var/lib/kube-router/kubeconfig": read /var/lib/kube-router/kubeconfig: is a directory

output of kubectl describe:

Normal   Pulling    35m (x12 over 49m)   kubelet, bridge19102  Pulling image "docker.io/cloudnativelabs/kube-router"
  Warning  Failed     30m (x31 over 37m)   kubelet, bridge19102  Error: ImagePullBackOff
  Normal   BackOff    20m (x73 over 37m)   kubelet, bridge19102  Back-off pulling image "docker.io/cloudnativelabs/kube-router"
  Warning  BackOff    31s (x140 over 49m)  kubelet, bridge19102  Back-off restarting failed container
4 Answers

This is a community wiki answer based on the comments and posted for better visibility.

The error message: Failed to parse kube-router config: Failed to build configuration from CLI: Error loading config file "/var/lib/kube-router/kubeconfig": read /var/lib/kube-router/kubeconfig: is a directory indicates that the path to the config file was not found and it points to a directory instead.

As you already found out, removing the directory and making it a file is a working resolution for this problem.

I had the same problem today when I used kind. Removing directory and creating a file doesn't seems a correct solution. I could not get why this happens, while earlier it worked nicely for me. It turned out I have not used a correct daemon file. Initially I was using https://raw.githubusercontent.com/cloudnativelabs/kube-router/master/daemonset/kube-router-all-service-daemonset.yaml then https://raw.githubusercontent.com/cloudnativelabs/kube-router/v1.3.2/daemonset/kube-router-all-service-daemonset.yaml and had this problem. I started look my logs and find out that when I used with kubeadm I was using kubeadm specific one. As kind uses kubeadm under the hood I used command for kubeadm which is

KUBECONFIG=/etc/kubernetes/admin.conf kubectl apply -f https://raw.githubusercontent.com/cloudnativelabs/kube-router/v1.3.2/daemonset/kubeadm-kuberouter-all-features.yaml

Then the problem gone. But I got another one CoreDNS stuck in ContainerCreating.

Note I did an attempt to use v1.3.2, while daemonset doesn't have tag and still uses kube-router v1.4.0.

sudo rmdir /var/lib/kube-router/kubeconfig && sudo touch /var/lib/kube-router/kubeconfig

After that, kube-router will eventually restart on its own, or I can delete the pods to force an immediate restart.

For more details, refer to: https://github.com/kubernetes/kops/issues/6169

Answering this since none of the listed answers here solved my issue:

Checking pod logs: kubectl logs -n kube-system kube-router-79h7d -p | less

  • Returned: Failed to get pod CIDR from node spec

1.) Find my Cluster's CIDR: https://devops.stackexchange.com/questions/5898/how-to-get-kubernetes-pod-network-cidr

I used this: kubeadm config print init-defaults

2.) Patch the kube-router pods to correct the CIDR:

kubectl get nodes -o name | xargs -I {} kubectl patch {} -p '{"spec":{"podCIDR":"10.96.0.0/12"}}'

via: https://github.com/cloudnativelabs/kube-router/issues/329

Related