<h3>Setup</h3>

<p>The pods of the deployment named frontend are exposed via a service named frontend.</p>

<pre><code>NAME                          READY     STATUS    RESTARTS   AGE
po/frontend-b48b88789-dcxs6   1/1       Running   0          2h

NAME              DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deploy/frontend   1         1         1            1           2h

NAME           TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE
svc/frontend   ClusterIP   10.106.243.125   &lt;none&gt;        80/TCP    2h
</code></pre>

<h3>Problem</h3>

<p>Querying via busybox the DNS name for the service frontend returns the services ip address. 
Querying via busybox the DNS name for the pod frontend-b48b88789-dcxs6 doesn't resolve.</p>

<pre><code>/ # nslookup frontend
Server:    10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local

Name:      frontend
Address 1: 10.106.243.125 frontend.exam.svc.cluster.local
/ # nslookup frontend-b48b88789-dcxs6
Server:    10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local

nslookup: can't resolve 'frontend-b48b88789-dcxs6'
</code></pre>

<hr>

<h3>Question</h3>

<p>What do I have to do to make a pod resolvable via the Kubernetes clusters DNS system?</p>

<p><em>Sources I have been looking for an answer</em></p>

<ul>
<li><em><a href="https://kubernetes.io/docs/tasks/administer-cluster/dns-custom-nameservers/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/administer-cluster/dns-custom-nameservers/</a></em></li>
<li><em><a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/</a></em></li>
</ul>

<p>I think that if you really need this, then what you actually might be interested in is <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">StatefulSet</a> which provides a somewhat static way of referencing to the pods that are spinned up by it. With StatefulSet, your pods will have a predictable name like <code>myapp-0</code>, <code>myapp-1</code> etc. and you will be able to resolve them as ie. <code>myapp-0.mysvc</code> (where <code>mysvc</code> is a "governing" service for the statefulset)</p>

<p>Predictable names allow for easier configuration of things that need to form a cluster, plus you get other gains like sequential scaling, mapping of persistent storage or ability to create services that always hit given pod (as in pod number N) of the StatefulSet meaning you are for example capable of creating a <code>myapp-0</code> service that always points to a <code>myapp-0.mysvc</code> pod.</p>
