使用下面的脚本部署 nodelocaldns
sed 's/k8s.gcr.io/gcr.azk8s.cn\/google_containers/g
s/__PILLAR__DNS__SERVER__/10.96.0.10/g
s/__PILLAR__CLUSTER__DNS__/10.96.0.10/g
s/__PILLAR__LOCAL__DNS__/169.254.20.10/g
s/__PILLAR__DNS__DOMAIN__/cluster.local/g
s/__PILLAR__UPSTREAM__SERVERS__/\/etc\/resolv.conf/g' nodelocaldns.yaml |
kubectl apply -f -
部署总是失败,pod 的状态为 CrashLoopBackOff
$ kubectl get pods --all-namespaces -l k8s-app=node-local-dns
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system node-local-dns-bbljm 0/1 CrashLoopBackOff 6 6m37s
查看 pod 的日志
kubectl logs -n kube-system -f daemonset/node-local-dns --all-containers=true --since=10m
发现下面 forwarding loop 错误
[FATAL] plugin/loop: Forwarding loop detected in "cluster.local." zone. Exiting. See https://coredns.io/plugins/loop#troubleshooting. Probe query: "HINFO 5710618306387078039.732983008356508997.cluster.local.".
请问如何解决?
是 __PILLAR__DNS__SERVER__
与 __PILLAR__CLUSTER__DNS__
使用了同样的 IP 地址引起的
bind 169.254.20.10 10.96.0.10
forward . 10.96.0.10 {
force_tcp
}
实际上并不需要替换 __PILLAR__CLUSTER__DNS__
为 IP 地址,最终的部署脚本如下:
sed 's/k8s.gcr.io/gcr.azk8s.cn\/google_containers/g
s/__PILLAR__DNS__SERVER__/10.96.0.10/g
s/__PILLAR__LOCAL__DNS__/169.254.20.10/g
s/__PILLAR__DNS__DOMAIN__/cluster.local/g' nodelocaldns.yaml |
kubectl apply -f -