coreDNS-CrashLoopBackOff

coreDNS-CrashLoopBackOff

Scroll Down

第一种情形

前:

刚搭建的k8s集群一切ok,所有kube-system的pod状态都是Running,当尝试部署dashboard之后,coreDNS状态都变为了CrashLoopBackOff

image.png

使用logs查看详细原因为

Failed to list *v1?limit=500&resourceVersion=0: dial tcp 10.96.0.1:443: connect: no route to host
image.png

解决:

# 将dns设置为公有dns服务器
# vim /etc/resolv.conf

image.png

# 重启服务
# systemctl daemon-reload
# systemctl restart docker

第二种情形:

前:

dashboard的各种问题解决之后就把虚拟机挂起了,重新启动之后发现dashboard和coreDNS的状态全部变成了CrashLoopBackOff,同样logs查看,与上边是一样的报错,这下第一种情形的解决方法已经不管用了,于是我又去查询了资料,最终在stackoverflow发现了解决办法:

systemctl stop kubelet
systemctl stop docker
iptables --flush
iptables -tnat --flush
systemctl start kubelet
systemctl start docker

翻译: 这样做的原因是,集群生命周期已经遇到了许多与flannel有关的问题(无论是在kubeadm还是kops tickets中),并且由于该项目没有得到积极维护,我们对用户没有很好的答案。

原回答: The reason for that is that Cluster Lifecycle have been getting a number of issues related to flannel (either in kubeadm or kops tickets) and we don't have good answers for the users as the project is not actively maintained. - Add note that issues for CNI should be logged in the respective issue trackers and that Calico is the only CNI we e2e test kubeadm against.

参考来源:
1、https://stackoverflow.com/questions/61315967/coredns-crashes-with-error-failed-to-list-v1-service-get-https-10-96-0-144
2、https://blog.csdn.net/qq_24046745/article/details/93988920