<p>I need to create an endpoint with DNS instead of IP</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: NodePort
  ports:
    - port: 5432
      targetPort: 5432
      nodePort: 30004
---
apiVersion: v1
kind: Endpoints
metadata:
  name: my-service 
subsets:
  - addresses:
      - ip: **111.111.111.111** ** &lt; need change this to DNS
    ports:
      - port: 5432


</code></pre>
<p>Everything works fine with numerical IP, but I need to put my Postgres DNS instead, something like:</p>
<pre><code>subsets:
  - addresses:
      - ip: mypostgres.com
    ports:
      - port: 5432
</code></pre>
<p>But &quot;addresses&quot; only support numerical IP. I need some workaround to make this work.</p>

<p>if you want to connect to a remotely hosted database URI instead of IP you can use <strong>ExternalName</strong></p>
<pre><code>kind: Service
apiVersion: v1
metadata:
 name: mongo
spec:
 type: ExternalName
 externalName: ds149763.mlab.com
</code></pre>
<p>Please check out more : <a href="https://cloud.google.com/blog/products/gcp/kubernetes-best-practices-mapping-external-services" rel="nofollow noreferrer">https://cloud.google.com/blog/products/gcp/kubernetes-best-practices-mapping-external-services</a></p>
