apiVersion: v1
kind: ConfigMap
metadata:
  name: patroni-config
data:
  PATRONI_CONFIG: |
    bootstrap:
      post_bootstrap: /usr/share/scripts/patroni/post_init.sh
      dcs:
        postgresql:
          use_pg_rewind: true
          parameters:
            max_connections: 1500
            max_prepared_transactions: 0
            max_locks_per_transaction: 64
      initdb:
      - auth-host: md5
      - auth-local: trust
      - encoding: UTF8
      - locale: en_US.UTF-8
      - data-checksums
      pg_hba:
      - host     all             all             0.0.0.0/0               md5
      - host     all             all             ::/0                    md5
      - local    all             all                                     md5
      - host     all             all        127.0.0.1/32                 md5
      - host     all             all        ::1/128                      md5
      - host replication ${PATRONI_REPLICATION_USERNAME} ${POD_IP}/16    md5
    restapi:
      connect_address: \"${POD_IP}:8008\"
    postgresql:
      listen: '*'
      connect_address: \"${POD_IP}:5432\"
      authentication:
        superuser:
          password: \"${PATRONI_SUPERUSER_PASSWORD}\"
        replication:
          password: \"${PATRONI_REPLICATION_PASSWORD}\"
