coredns crashloopbackoff in kubernetes

邮差的信 提交于 2019-12-20 04:28:10

问题


I have setup kubernetes in ubuntu 16.04. I am using kube version 1.13.1 and using weave for networking. I have initialized the cluster using :

sudo kubeadm init --token-ttl=0 --apiserver-advertise-address=192.168.88.142

and weave:

kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"

All the pods seems to be running fine but coredns always remains in CrashLoopBackOff status. I have read mostly all the solution available for this.

NAME                                READY   STATUS             RESTARTS   AGE
coredns-86c58d9df4-h5plc            0/1     CrashLoopBackOff   7          18m
coredns-86c58d9df4-l77rw            0/1     CrashLoopBackOff   7          18m
etcd-tx-g1-209                      1/1     Running            0          17m
kube-apiserver-tx-g1-209            1/1     Running            0          17m
kube-controller-manager-tx-g1-209   1/1     Running            0          17m
kube-proxy-2jdpp                    1/1     Running            0          18m
kube-scheduler-tx-g1-209            1/1     Running            0          17m
weave-net-npgnc                     2/2     Running            0          13m

I initially started by editing the cordens file and deleting the loop. It resolves the issue but then later I realized that I wasn't able to ping www.google.com from within the container but I was able to ping the ip address of google.com. Thus deleting the loop is not a perfect solution.

Next I tried looking at the /etc/resolv.conf and found below contents:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.1.1
search APSDC.local

Here is the workaround provided on kubernetes page which says that any type IP address like 127.0.0.1 should be avoided. I am not able to understand this line as this file is automatically generated. How can make changes to the file so that coredns can work fine. Belo is the logs of coredns:

$ kubectl logs coredns-86c58d9df4-h5plc -n kube-system

.:53
2019-01-31T17:26:43.665Z [INFO] CoreDNS-1.2.6
2019-01-31T17:26:43.666Z [INFO] linux/amd64, go1.11.2, 756749c
CoreDNS-1.2.6
linux/amd64, go1.11.2, 756749c
[INFO] plugin/reload: Running configuration MD5 = f65c4821c8a9b7b5eb30fa4fbc167769
[FATAL] plugin/loop: Forwarding loop detected in "." zone. Exiting. See https://coredns.io/plugins/loop#troubleshooting. Probe query: "HINFO 1423429973721138313.4523734933111484351.".

Can anyone please point me to right direction in order to resolve this issue. Please help. Thanks


回答1:


I have resolved this issue. In my case I had below contents of /etc/resolv.conf

nameserver     127.0.1.1

I first used the below command to get the correct IP as the device was in client's network.

nmcli device show <interfacename> | grep IP4.DNS

After this I updated the file /etc/resolvconf/resolv.conf.d/head with below contents

nameserver    192.168.66.21

and then run the below command to regenerate the resolv.conf

sudo resolvconf -u

After this I had below contents in /etc/resolv.conf:

nameserver    192.168.66.21
nameserver    127.0.1.1

I then deleted the coredns pods and everything worked fine. Thanks.



来源:https://stackoverflow.com/questions/54466359/coredns-crashloopbackoff-in-kubernetes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!