<p>I was left to a configuration of Kubernetes which contains two distinct instances of a master-replica service. The pods of both the master and the replicas contain both the container of the service and a metric collection container (therefore for each pod there are two different containers). In addition, I have a service headless that aims at all three that will then be used by other components. The point is that the &quot;replicas&quot; need to access the Master, and the classic DNS nomenclature &quot;Master-Pod-Name.Service-Name.Namespace.Svc.Cluster.local&quot; is not working (it was already set in this way in variables)  I did some lookup tests etc and obviously it only works if I use &quot;service-name.Namespace.svc.cluster.local&quot;, however, that service aims at all 3 instances and I have to point only to the master.
My doubt is that I cannot solve it because there are several containers in that pod but I do not find references to how to indicate the correct DNS in the documentation.</p>
<p>I also tried to configure</p>
<pre><code>dnsConfig:
        options:
        - name: ndots
          value: &quot;6&quot;
</code></pre>
<p>Then putting as DNS Container-Name.pod-Name.Service-Name.Namespace.Svc.Cluster.local but nothing has changed anyway.</p>
<p>The environment I am working on is a gke cluster (Kubernetes on Google Cloud).</p>

William.P
<p>Make sure that your application is deployed as a stateful set together with a headless service. Only stateful sets guarantee the stable network IDs that you want to use in your DNS lookups:</p>
<p><a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id</a></p>
