coredns: CoreDNS service (kube-dns) unreachable from pods
What happened: Pods are unable to use CoreDNS because it’s service IP is unreachable. If we try to use an specific CoreDNS pod to query a domain, it works as expected.
What you expected to happen: For the pods to be able to use the CoreDNS service as is.
How to reproduce it (as minimally and precisely as possible): Based on the Kubernetes Debugging DNS Resolution, the following command results in timeout:
$ kubectl exec dnsutils nslookup kubernetes.default
;; connection timed out; no servers could be reached
command terminated with exit code 1
If I use one specific CoreDNS pod from our cluster (10.96.224.26 in our case), it works as expected:
$ kubectl exec dnsutils nslookup kubernetes.default 10.96.224.26
Server: 10.96.224.26
Address: 10.96.224.26#53
Name: kubernetes.default.svc.cluster.local
Address: 10.96.0.1
Anything else we need to know?:
Our cluster was initialized with:
kubeadm init --pod-network-cidr=10.96.0.0/16
And our CNI is Weave.
Here are some other outputs to help understand our cluster:
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
fesc-lnx-dss10 Ready master 14d v1.17.3
fesc-lnx-dss11 Ready <none> 14d v1.17.3
fesc-lnx-dss12 Ready <none> 14d v1.17.3
fesc-lnx-dss13 Ready <none> 14d v1.17.3
$ kubectl exec dnsutils cat /etc/resolv.conf
nameserver 10.96.0.10
search default.svc.cluster.local svc.cluster.local cluster.local fesc.sgusuite.com.br
options ndots:5
$ kubectl get svc -n kube-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 14d
$ kubectl get pods --namespace=kube-system -l k8s-app=kube-dns -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
coredns-8c4578697-frxlj 1/1 Running 0 20h 10.96.224.26 fesc-lnx-dss11 <none> <none>
coredns-8c4578697-p2mwn 1/1 Running 0 20h 10.96.96.26 fesc-lnx-dss12 <none> <none>
coredns-8c4578697-pbq78 1/1 Running 0 20h 10.96.0.3 fesc-lnx-dss10 <none> <none>
coredns-8c4578697-s8psk 1/1 Running 0 20h 10.96.128.26 fesc-lnx-dss13 <none> <none>
Btw, If I run nslookup directly on the master node or any worker node using the CoreDNS service (10.96.0.10) it works just fine:
$ nslookup google.com 10.96.0.10
Server: 10.96.0.10
Address: 10.96.0.10#53
Non-authoritative answer:
Name: google.com
Address: 172.217.29.14
Name: google.com
Address: 2800:3f0:4001:80a::200e
The problem seems to be querying this from inside the pod only.
Environment:
-
the version of CoreDNS: CoreDNS-1.6.5
-
Corefile:
.:53 {
log
errors
health {
lameduck 5s
}
ready
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
fallthrough in-addr.arpa ip6.arpa
ttl 30
}
prometheus :9153
forward . /etc/resolv.conf
cache 30
loop
reload
loadbalance
}
- OS: CentOS 7
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (2 by maintainers)
kubeadm init --pod-network-cidr=10.96.0.0/16Your pod network and your service network overlap … which I imagine will cause routing problems.
I got same issue. In my case, I setup cluster (kubeadm) on AWS EC2 instances.
Solution: After I change Security Group (firewall) setting to allow all traffic then everything back to normal.
I never got this issue when setup cluster on bare metal.
The root cause should be firewall setting on cloud provider.
Hope it help!
Great!
So, I assume that can able to do that:
$ kubeadmin init --pod-network-cidr=192.168.0.0/17 --service-cidr=192.168.128.0/17I will try. Thanks @rafaelrenanpacheco !@chrisohaver we reinstalled our cluster with
kubeadm init --pod-network-cidr=10.96.0.0/16 --service-cidr=10.97.0.0/16and CoreDNS is now working as expected 🎉
Thanks again!
@chrisohaver thanks for the fast response!
Indeed they are overlapping, since service-cidr defaults to 10.96.0.0/12.
We will have to reset our cluster and init it with a proper service-cidr range.
Thanks!
This is not a CoreDNS issue, rather a Kubernetes networking problem, where traffic to Cluster IPs is not correctly directed to Pods. I expect that this affects all of your Cluster IP services, not just the CoreDNS service.
From the description, the issue could lie in kube-proxy.
Here’s A troubleshooting guide … https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/