<p>So I have a deployment which creates N number of worker pods, and a service which internally balanced traffic to them.  I access the service from a VM.  The VM makes a request, and the pod responds with its hostname so that the VM can make a direct connection to it (this is used for pulling the results back from the pod that actually did the work).</p>

<p>The problem that I'm having is that my pod is returning a hostname of my-pod-5ff75ddd86-2xdjq which the VM cannot resolve.  I'm wondering if it's possible to set the hostname of the pod to its IP, as this would mean I don't have to change any code in my pod, or the tool running in my VM.</p>

Andy
<p>In case you don't want to change your code you need to expose the internal <code>kube-dns</code> of your cluster and make it the default DNS server of your VM.</p>

<p>On that another question have some info</p>

<p><a href="https://stackoverflow.com/questions/37449121/how-to-expose-kube-dns-service-for-queries-outside-cluster">How to expose kube-dns service for queries outside cluster?</a></p>

<p>On the nginx-controller documentation you have a good example of exposing the 53 port on UDP</p>

<p><a href="https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/</a></p>

<p>By having a nginx-controller up and running you have to create an ingress correctlly to be used by this controller and simply add this <code>configMap</code>:</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: udp-services
  namespace: ingress-nginx
data:
  53: "kube-system/kube-dns:53"
</code></pre>
