是否可以反向dns查询POD IP地址以获取Kubernetes部署的主机名



我有一个部署,其中副本可以上下扩展,所有副本都在无头服务下。我可以查询。。svc.cluster.local,返回所有pod IP的列表。

我想知道是否可以查询每个pod IP并获得pod的主机名?它适用于同一主机上的Pods。但它并不能从其他主机上解析pod。

我注意到它适用于StatefulSet。但它不适用于部署。

这里已经讨论过kube-dns。这里也有更多的讨论。

然而,PTR记录对我来说适用于coredns和K8s 1.12:

$ 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