- 
      
- 
        Save michaljemala/cf74ccef74e5ae9ea41aaeba4bcc6a46 to your computer and use it in GitHub Desktop. 
| version: '3.8' | |
| services: | |
| pgmaster: | |
| image: bitnami/postgresql:latest | |
| ports: | |
| - 5432 | |
| volumes: | |
| - pgmaster_data:/bitnami/postgresql | |
| environment: | |
| - POSTGRESQL_REPLICATION_MODE=master | |
| - POSTGRESQL_REPLICATION_USER=postgres | |
| - POSTGRESQL_REPLICATION_PASSWORD=s3cret | |
| - POSTGRESQL_PASSWORD=s3cret | |
| - POSTGRESQL_DATABASE=platform | |
| pgslave: | |
| image: bitnami/postgresql:latest | |
| ports: | |
| - 5432 | |
| depends_on: | |
| - pgmaster | |
| environment: | |
| - POSTGRESQL_REPLICATION_MODE=slave | |
| - POSTGRESQL_REPLICATION_USER=postgres | |
| - POSTGRESQL_REPLICATION_PASSWORD=s3cret | |
| - POSTGRESQL_MASTER_HOST=pgmaster | |
| - POSTGRESQL_PASSWORD=s3cret | |
| pgpool: | |
| image: docker.io/bitnami/pgpool:latest | |
| ports: | |
| - 5432:5432 | |
| depends_on: | |
| - pgmaster | |
| volumes: | |
| - ./pgpool.conf:/config/pgpool.conf | |
| environment: | |
| - PGPOOL_USER_CONF_FILE=/config/pgpool.conf | |
| - PGPOOL_BACKEND_NODES=0:pgmaster:5432:4:master:ALWAYS_MASTER,1:pgslave:5432:6:replica1 | |
| - PGPOOL_SR_CHECK_USER=postgres | |
| - PGPOOL_SR_CHECK_PASSWORD=s3cret | |
| - PGPOOL_ENABLE_LDAP=no | |
| - PGPOOL_POSTGRES_USERNAME=postgres | |
| - PGPOOL_POSTGRES_PASSWORD=s3cret | |
| - PGPOOL_ADMIN_USERNAME=admin | |
| - PGPOOL_ADMIN_PASSWORD=s3cret | |
| - PGPOOL_ENABLE_LOAD_BALANCING=yes | |
| - PGPOOL_ENABLE_STATEMENT_LOAD_BALANCING=yes | |
| - PGPOOL_NUM_INIT_CHILDREN=10 | |
| - PGPOOL_MAX_POOL=1 | |
| - PGPOOL_EXTRA_FLAGS=-d | |
| volumes: | |
| pgmaster_data: | 
Hello @petre-c The env variable is used to define the nodes in pgPool cluster. You can see more detailed info here: https://github.com/bitnami/containers/blob/a5510700758f036fc681f43eea79c33d49c8e11a/bitnami/pgpool/4/debian-12/rootfs/opt/bitnami/scripts/libpgpool.sh#L179-L192.
To illustrate the example this specific line 0:pgmaster:5432:4:master:ALWAYS_MASTER,1:pgslave:5432:6:replica1 describes a 2 nodes cluster:
- Master
- NodeID=0
- Host=pgmaster
- Port=5432
- Weight=4 (40%)
- DataDir=master
- Replica
- NodeID=1
- Host=pgslave
- Port=5432
- Weight=6 (60%)
- DataDir =replica1
As per the code: https://github.com/bitnami/containers/blob/main/bitnami/pgpool/4/debian-12/rootfs/opt/bitnami/scripts/libpgpool.sh#L401-L427, it will result in pgpool config snippet as follows:
backend_hostname0 = 'pgmaster'
backend_port0 = 5432
backend_weight0 = 4
backend_data_directory0 = 'master'
backend_hostname1 = 'pgslave'
backend_port1 = 5432
backend_weight1 = 6
backend_data_directory1 = 'replica1'
You can see an example of this in the docs: https://www.pgpool.net/docs/latest/en/html/example-replication-mode.html#EXAMPLE-REPLICATION-MODE-BACKEND-SETTINGS
@michaljemala , can you elaborate on this line? Documentation page for bitnami/pgpool doesn't mention these extra options