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 outside the cluster to simulate the production environment.
It seems that the way to do this is by defining an external endpoint as described here: Minikube expose MySQL running on localhost as service
Unfortunately, I am not able to specify "127.0.0.1" as the Endpoint IP address:
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)
So I am forced to bind postgres to my actual machine address.
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.
Anybody know the trick? Or alternatively, can someone suggest an alternative solution which doesn't involve running postgres inside the cluster?