Hello everyone. We run our software in GKE and use...
# google-cloud
Hello everyone. We run our software in GKE and use PostgreSQL Cloud SQL as database backend. We want to use PgBouncer as connection pool middleware, implemented as a microservice in GKE. Is there any good Pulumi tutorial on how to achieve that? Thank you.
What are you struggling with?
Do you need some help with managing GKE and CloudSQL from pulumi or you’re asking how you can deploy PgBouncer within k8s cluster?
Well, the setup I see is this: • Create a Docker image with PgBouncer in it • Deploy it to GKE using Pulumi • Change the connection strings to point to PgBouncer instead of Cloud SQL
What is not clear to me is how to specify the correct connection string from PgBouncer to Cloud SQL. The official documentation recommends to connect to Cloud SQL using Cloud SQL Auth proxy and load it as sidecar in the same pod as, I assume, PgBouncer.
Does it mean that the connection will look like this: microservice -> PgBouncer -> Cloud SQL Auth proxy -> Cloud SQL?
In terms of hosts and ports, is it going to be something like: microservice: pgbouncer-service:6432 (example port) -> localhost:5432 -> <cloud-sql-connection-stringg>:5432 -> Cloud SQL?
… or is there a simpler way to deploy PgBouncer to GKE?
Did you enable private connection in Cloud SQL?
It’s possible to setup CloudSQL and GKE to communicate over private IP address. In that case, you can simply get rid of cloud sql proxy.
but the way you described it seems legit as well. That’s how I did it back in time when private connections were not available in GCP (although without PgBouncer)
If private connection is enabled, what should I specify as host in PgBouncer config file in the
IP address of the Cloud SQL instance
Great, thank you!
you can get this value from
output 🙂