<p>I am new to Kubernetes, and I am trying to make inter-pod communication over DNS to work. </p>

<p>Pods in My k8s are spawned using Deployments. My problem is all the Pods report its hostname to Zookeeper, and pods use those hostnames found in Zookeeper to ping the other peers. It always fail because the peer's hostnames are unresolvable between pods.</p>

<p>The only solution now is to manually add each pod's hostname to peer's /etc/hosts file. But this method would not endure to work for large clusters. </p>

<p>If there is a DNS solution for inter-pod communication, that keeps a record of any newly generated pods, and delete dead pods, will be great. </p>

<p>Thanks in advance.</p>

Minera Fanhiri
<p>You need to use a service definition pointing to your pods</p>

<p><a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/</a></p>

<p>With that you have a balanced proxy to control the inter-pod communications and the internal DNS on Kubernetes takes care of that service instead of each pod no matter the state of the pod. </p>

<p>If that simples solution didn't fit your needs you can substitute kubedns as the default internal DNS by using coreDNS.</p>

<p><a href="https://coredns.io/" rel="nofollow noreferrer">https://coredns.io/</a></p>
