<p>I have a deployment where the replicas scale up and down which are all under a headless service.  I am able to query ..svc.cluster.local which returns list of all pod IPs.</p>

<p>I wanted to know if its possible to query for each pod IP and get the hostname of the pod? It works for Pods on the same host machine. But its not resolving the pods from other hosts.</p>

<p>I noticed that it works for a StatefulSet. But its not working for Deployment.</p>

<p>This has already been discussed <a href="https://stackoverflow.com/a/43256750/2989261">here</a> for <code>kube-dns</code>. There has been more discussion <a href="https://github.com/kubernetes/dns/issues/266" rel="nofollow noreferrer">here too</a>.</p>

<p>However, PTR records work fine for me with <code>coredns</code> and K8s 1.12:</p>

<pre><code>$ kubectl get pod helloworld-xxxxxxxxxx-xxxxx -o=jsonpath="{.metadata.annotations['cni\.projectcalico\.org/podIP']}" | cut -d "/" -f 1
192.168.11.28
# Connect to another pod   
$ kubectl exec -it anotherpod-svc-xxxxxxxxxx-xxxxx bash
root@anotherpod-xxxxxxxxxx-xxxxx:/# dig +short -x 192.168.11.28
192-168-11-28.helloworld.default.svc.cluster.local.
root@anotherpod-xxxxxxxxxx-xxxxx:/# dig +short 192-168-11-28.helloworld.default.svc.cluster.local
192.168.11.28

# Another helloworld pod on a different physical machine
$ kubectl get pod helloworld-xxxxxxxxxx-xxxxx -o=jsonpath="{.metadata.annotations['cni\.projectcalico\.org/podIP']}" | cut -d "/" -f 1
192.168.4.6
# Connect to another pod   
$ kubectl exec -it anotherpod-svc-xxxxxxxxxx-xxxxx bash
root@anotherpod-svc-xxxxxxxxxx-xxxxx:/# dig +short -x 192.168.4.6
192-168-4-6.helloworld.default.svc.cluster.local.
root@anotherpod-xxxxxxxxxx-xxxxx:/# dig +short 192-168-4-6.helloworld.default.svc.cluster.local
192.168.4.6
</code></pre>
