<p>Scenario:</p>
<ul>
<li><p>Tableau application;</p>
</li>
<li><p>Postgres on a cloud;</p>
</li>
<li><p>Kubernetes on another cloud, running an application based on Alpine image (different cloud than Postgres).</p>
</li>
</ul>
<p>What a I need:</p>
<ul>
<li>Access Postgres from Tableau using Kubernetes as a kind of router;
So I need to send a request to my Kubernetes cluster, from tableau, and my Kubernetes cluster need to redirect the requisition to my Postgres host, and Postgres must to answer back to my kubernetes cluster after that my Kubernetes cluster must send de answer from Postgres to Tableau.</li>
</ul>
<p><strong>Important restrictions:</strong></p>
<ul>
<li><p>Tableau can access my kubernetes cluster but cannot access my Postgres host directly;</p>
</li>
<li><p>My kubernetes cluster can access my Postgres host.</p>
</li>
</ul>
<hr />
<p><strong>Next steps</strong>
Now I was able to make it work by using Thomas answer, using the following code:</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 hostname
    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>You can achieve this by creating service type object without selectors and then manually creating endpoints for this its. Service needs to expose outside either via <code>NodePort</code> or <code>Loadbalancer</code> type:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: my-service #Name of the service must match the name of the endpoints
spec:
  type: NodePort
  ports:
    - port: 80
      targetPort: 80
      nodePort: 30007
</code></pre>
<p>Services don’t link to pods directly. There is another object in between called endpoints. Because of this you are able to define them manually.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Endpoints
metadata:
  name: my-service #Name of te endpoint must match the name of the service
subsets:
  - addresses:
      - ip: 172.217.212.100 # This is the IP of the endpoints that the service will forward connections to. 
    ports:
      - port: 80
</code></pre>
<p>Since you are going to expose your postgres some sort securiy measures has to be taken in order to secure it, e.g. <a href="https://www.springboard.com/blog/what-is-whitelisting/#:%7E:text=IP%20Whitelists,updated%20by%20the%20site%20administrator." rel="nofollow noreferrer">whitelist ip</a></p>
<p>For more reading please visit <a href="https://kubernetes.io/docs/concepts/services-networking/service/#services-without-selectors" rel="nofollow noreferrer">/Services without selectors</a> .</p>
