在部署完成k8s服务后,发现coredns组件状态存在异常,并且日志报错:
[admin@localhost ~]$ kubectl logs --tail 20 -n kube-system coredns-68978987c9-gfq5h
[INFO] plugin/reload: Running configuration MD5 = 2b18e8c07cb255fc312c89e15c1280d3
CoreDNS-1.8.0
linux/amd64, go1.15.3, 054c9ae
[FATAL] plugin/loop: Loop (10.244.0.1:45870 -> :53) detected for zone ".", see https://coredns.io/plugins/loop#troubleshooting. Query: "HINFO 6238558190786240769.4449342423357158470."
解决办法
修改HINFO类型返回
设置返回一个NXDOMAIN的响应码,增加以下内容:
template ANY HINFO . {
rcode NXDOMAIN
}
示范:
[root@localhost ~]# kubectl edit cm -n kube-system coredns
.:53 {
template ANY HINFO . {
rcode NXDOMAIN
}
errors
health {
lameduck 5s
}
ready
kubernetes kubernetes in-addr.arpa ip6.arpa {
pods insecure
fallthrough in-addr.arpa ip6.arpa
}
prometheus :9153
forward . /etc/resolv.conf {
prefer_udp
}
cache 30
loop
reload
loadbalance
hosts /etc/coredns/hosts {
fallthrough
}
}
编辑完成后重启对应pod