While trying to setup a Postgres HA cluster with spilo on 3 Docker nodes (post), I had some issues with my VPN mesh. I wanted the containers only to listen on the VPN IPs, but then they could not connect to each other. It turns out that an internal Docker IP is automatically written to DCS, then other instances try to use it to connect.
I had to use a not-so-nice work-around, even though Patroni provides an env var PATRONI_POSTGRESQL_CONNECT_ADDRESS for this.
# .env.example
HOSTNAME=db-1 # unique per node
HOST=db-1.internal # unique per node
HOST_IP=100.64.0.1 # unique per node
HOST_1=db-1.internal
HOST_2=db-2.internal
HOST_3=db-3.internal
services:
spilo:
image: ghcr.io/zalando/spilo-17:4.0-p2
container_name: spilo
hostname: ${HOSTNAME}
ports:
- "${HOST_IP}:5432:5432"
- "${HOST_IP}:8008:8008"
volumes:
- ./data:/home/postgres/pgdata
environment:
SPILO_PROVIDER: local
SCOPE: postgres-cluster
RESTAPI_CONNECT_ADDRESS: ${HOST}
POSTGRESQL_CONNECT_ADDRESS: ${HOST} ### not working
SPILO_CONFIGURATION: |
postgresql:
connect_address: ${HOST}:5432
ETCD3_HOSTS: ${HOST_1}:2379,${HOST_2}:2379,${HOST_3}:2379
restart: unless-stopped
Can POSTGRESQL_CONNECT_ADDRESS be added as official supported spilo env var?
While trying to setup a Postgres HA cluster with
spiloon 3 Docker nodes (post), I had some issues with my VPN mesh. I wanted the containers only to listen on the VPN IPs, but then they could not connect to each other. It turns out that an internal Docker IP is automatically written to DCS, then other instances try to use it to connect.I had to use a not-so-nice work-around, even though Patroni provides an env var
PATRONI_POSTGRESQL_CONNECT_ADDRESSfor this.Can
POSTGRESQL_CONNECT_ADDRESSbe added as official supported spilo env var?