<p>I have a situation where I have a Kubernetes cluster that has access to a Postgres instance (which is not run in the Kubernetes cluster). The Postgres instance is not accessible from anywhere else.</p>
<p>What I would like to do is connect with my Database tools locally. What I have found is <code>kubectl port-forward</code> but I think this would only be a solution if the Postgres instance is run as a pod. What I basically need is a Pod, that forwards everything that is sent on Port 8432 to the postgres instance and then I could use the port forward.</p>
<p><a href="https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/</a></p>
<p>What is the right way to do this?</p>

nino
<p>You can create service for your postgresql instance:</p>
<pre class="lang-yaml prettyprint-override"><code>---
apiVersion: v1
kind: Service
metadata:
  name: postgresql
spec:
  ports:
    - port: 5432

---
apiVersion: v1
kind: Endpoints
metadata:
  name: postgresql
subsets:
  - addresses:
      - ip: ipAddressOfYourPGInstance
    ports:
      - port: 5432
</code></pre>
<p>And then use:
<code>kubectl port-forward service/postgresql 5432:5432</code></p>
