zalando / postgres-operator

Postgres operator creates and manages PostgreSQL clusters running in Kubernetes
https://postgres-operator.readthedocs.io/
MIT License
4.37k stars 980 forks source link

pgbouncer read write in one place #2726

Closed dragoangel closed 3 months ago

dragoangel commented 3 months ago

PgBouncer allows setting in one instance different hosts for reads and writes, and technically there no need in enableReplicaConnectionPooler, because one pgbouncer are handling both reads and writes in a way:

[databases]
reads = host=mycluster-repl port=5432 auth_user=connpuller
writes = host=mycluster port=5432 auth_user=connpuller

To achieve it we need:

  1. update acid/pgbouncer docker image to accept PGHOST_READS and PGHOST_WRITES
  2. change /etc/pgbouncer/pgbouncer.ini.tmpl to include proposed reads\writes separation
  3. change postgres-operator to remove or depracate enableReplicaConnectionPooler (we can in depracate mode create service that will route to same pgbouncer that handles reads\writes)
  4. change postgres-operator to use newer version of acid/pgbouncer and set both PGHOST_READS and PGHOST_WRITES. If cluster has only 1 node, which means only one master without replicas - we can set reads and writes to master for simplicity
dragoangel commented 3 months ago

Looks like I missread some post, it can't do this way