proxy.pgBouncer section to your PostgresCluster spec and the operator manages the Deployment, Service, TLS certificates, and user authentication automatically.
Enable pgBouncer
The minimal configuration is an emptypgBouncer object. This starts one pgBouncer pod in transaction pooling mode using PGO defaults.
Configure pool size and mode
Usespec.proxy.pgBouncer.config.global to set any pgBouncer configuration parameter. Key settings include pool_mode, max_client_conn, and default_pool_size.
Changes to
config.global are reloaded automatically without restarting pgBouncer. However, invalid configuration values can put pgBouncer into an unusable state, so validate your settings before applying.Scale pgBouncer replicas
For high-traffic clusters, run multiple pgBouncer pods behind the Kubernetes Service. Each pod maintains its own connection pools independently.Database routing
By default, pgBouncer routes all connections through a wildcard (*) entry that targets the primary PostgreSQL instance. Use config.databases to define explicit routing rules with libpq-style connection strings.
Per-user settings
config.users lets you apply pgBouncer settings for specific database users, such as overriding the pool size or pool mode.
Expose pgBouncer externally
By default the pgBouncer Service isClusterIP. Change spec.proxy.pgBouncer.service.type to expose it via a LoadBalancer or NodePort.
Retrieve the connection endpoint
1
Find the pgBouncer Service
2
Get the pgBouncer connection secret
PGO writes pgBouncer connection details into the per-user secret alongside the direct Postgres connection string. The key
pgbouncer-uri contains a connection URI pointing at the pgBouncer Service.3
Connect through pgBouncer
Use the
pgbouncer-uri in your application. The URI points to the pgBouncer Service on port 5432 (the default), using the same credentials as the direct connection.Direct Postgres vs. pgBouncer
Use the right endpoint for each workload type:Custom TLS for pgBouncer
To supply your own TLS certificate for the pgBouncer endpoint, reference aSecret projection containing tls.crt, tls.key, and ca.crt:
Create a cluster
Configure instances, storage, and Postgres parameters.
High availability
Run multiple replicas with automatic failover via Patroni.
TLS
Manage certificates for encrypted Postgres and pgBouncer connections.
Custom Resource Reference
Full field reference for
spec.proxy.pgBouncer.