I have kube-dns running in a (bare metal) cluster. I know that it works, as I can interpolate a service to a name I've created and get a host entry:
$ host elk-service-headless.default.svc.cluster.local
elk-service-headless.default.svc.cluster.local has address 10.42.0.151
elk-service-headless.default.svc.cluster.local has address 10.42.0.152
elk-service-headless.default.svc.cluster.local has address 10.42.0.153
(...)
What I can't figure out how to do is to list all of the records that kube-dns is holding. I've tried the standard DNS tricks like dig and host -l
and can't get them. But in any case, there must be a way to do this from Kubernetes itself. I tried inspecting ConfigMaps and didn't find what I'm looking for.
Verify that the DNS service is up by using the kubectl get service command. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE ... kube-dns ClusterIP 10.0. 0.10 <none> 53/UDP,53/TCP 1h ...
The Domain Name System (DNS) is a system for associating various types of information – such as IP addresses – with easy-to-remember names. By default most Kubernetes clusters automatically configure an internal DNS service to provide a lightweight mechanism for service discovery.
You can do a DNS query from any pod and you would get the FQDN. cluster-domain. example is just a example in the documentation. cluster.
kube-dns is the authoritative name server for the cluster domain (cluster. local) and it resolves external names recursively. Short names that are not fully qualified, such as myservice , are completed first with local search paths.
This post will help you find the internal DNS record of your K8s services on a cluster that runs kube-dns:
kubectl -n kube-system get svc kube-dns
Now we know the internal K8s DNS resolver IP is 172.20.0.10
kubectl -n fe get ep
kubectl -n fe exec -it fe-app-575fdf6cb6-lt7t6 -- sh
If you are using kube-dns, it use dnsmaq to cache DNS record, you can dump record by this answer.
If you are using coredns, it embed a cache plugin to cache DNS record, and I find no way to get data in this cache plugin. But I find coredns can use etcd as backend, so the DNS record can be cached in etcd, but this need to reconfig your coredns with this Corefile:
.:53 {
etcd {
path /skydns
endpoint <etcd_endpoint>
upstream /etc/resolv.conf
}
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With