how can I list all kubernetes DNS records?

6/22/2019

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.

-- tedder42
kubernetes

1 Answer

6/23/2019

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
    }
    ...
}
-- menya
Source: StackOverflow