<p>I have below service running in my k8s pod. I want to access and ping service name &quot;service-plt-mediator&quot; from another pod. What needs to be added in manifest file of the pod so that the service name should be in /etc/host file and can be pinged from inside the pod?</p>
<pre><code>/home/ravi&gt;kubectl get svc | grep 
NAMESPACE     NAME                   TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                           AGE
plt        service-plt-mediator     ClusterIP   10.108.188.147   &lt;none&gt;        4561/TCP,4562/TCP                 3h47m

</code></pre>
<p>Tried to add entry using &quot;hostAlias&quot; in manifest file, but it needs a static IP also. Which I can not as the service IP will change after reboot</p>

myquest5 sh
<p>You don't need to add a mapping in <code>/etc/hosts</code>. Your pods <code>/etc/resolv.conf</code> is configured by <code>kubelet</code> to send DNS queries to CoreDNS service that is running in the cluster (You can see that default config in the pod spec as <code>dnsPolicy: ClusterFirst</code>). The DNS response will be the <code>clusterIP</code> of the Service.</p>
<p>You can use <code>&lt;service-name&gt;.&lt;namespace&gt;</code> as the DNS request name in the other pod.</p>
<p>You can debug your DNS in the cluster as described <a href="https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/" rel="nofollow noreferrer">here</a>.</p>
