During local development with Kubernetes/minikube, how should I connect to postgres database running on localhost? : <p>I've set up an application stack running on Google Kubernetes Engine + Google Cloud SQL. When developing locally, I would like my application to connect to a postgres database server running <em>outside</em> the cluster to simulate the production environment.</p>

<p>It seems that the way to do this is by defining an external endpoint as described here: <a href="https://stackoverflow.com/questions/43354167/minikube-expose-mysql-running-on-localhost-as-service">Minikube expose MySQL running on localhost as service</a></p>

<p>Unfortunately, I am not able to specify "127.0.0.1" as the Endpoint IP address:</p>

<pre><code>kubectl apply -f kubernetes/local/postgres-service.yaml
service "postgres-db" unchanged
The Endpoints "postgres-db" is invalid: subsets[0].addresses[0].ip: 
Invalid value: "127.0.0.1": may not be in the loopback range (127.0.0.0/8)
</code></pre>

<p>So I am forced to bind postgres to my actual machine address.</p>

<p>It seems like there MUST be a way to map a port from my localhost into the local kubernetes cluster, but so far I can't find a way to do it. </p>

<p>Anybody know the trick? Or alternatively, can someone suggest an alternative solution which doesn't involve running postgres inside the cluster?</p>
