pg_hba.conf settings not applied
Environment
Platform: Kubernetes Platform Version: 4.7.3 PGO Image Tag: centos8-4.7. Postgres Version: 13
Problem
My custom pg_hba.conf settings are not applied, it just uses the default settings.
Steps
I followed the custom config documentation to create a custom config-map with a postgres-ha.yaml entry. Below is a sample of that file. I've tried it as depicted without success.
bootstrap:
dcs:
postgresql:
parameters:
shared_preload_libraries: pg_stat_statements.so,pgnodemx.so,timescaledb
listen: '*'
postgresql:
pg_hba:
- local all postgres md5
- host all all 127.0.0.1/32 md5
- host all all 102.37.124.150/32 md5
- host all all 102.37.217.33/32 md5
After cluster creation I view the MYCLUSTER-pgha-config config-map, and there is always a local section with default settings: my custom settings are nowhere. I tried moving the pg_hba entry to various other locations in postgres-ha.yaml without success:
- Under bootstrap.dcs
- Under bootstrap.dcs.postgresql
- Under local.postgresql
- etc.
I also don't know what the correct way is to define a "local" entry. The documentation discusses it, but doesn't give an example of how to format it in postgres-ha.yaml. I can see in the generated MYCLUSTER-pgha-config config-map that there is an entry: MYCLUSTER-local-config, but I can't see what my postgres-ha.yaml entry must look like to get something in that local-config section.
Summary
- I don't know where to put pg_hba config in my
postgres-ha.yamlso that it overrides the default - I don't know, in general, how to define a "local" section in
postgres-ha.yaml
If this is a new deployment, I suggest starting with PGO v5
In v4, if you want the pg_hba.conf settings to be applied at boostrap time, the section is bootstrap.pg_hba. You can then also have an entry in the postgresql.pg_hba section.
As per the docs, I have tried putting it under bootstrap.pg_hba: it doesn't work. I deleted the cluster, re-created the custom config-map, re-created the cluster - pointing to the custom config-map. I then opened a shell in the master pod of the postgres cluster, viewed /pgdata/MYCLUSTER/pg_hba.conf, it still has the default settings:
# Do not edit this file manually!
# It will be overwritten by Patroni!
local all postgres peer
host replication primaryuser 0.0.0.0/0 md5
host all primaryuser 0.0.0.0/0 reject
host all all 0.0.0.0/0 md5
Then I tried putting it under postgresql.pg_hba: with this configuration, the main cluster pod never reaches ready status - pgo doesn't like that config.
Does the behaviour differ between v4 and v5? Is it worth upgrading to see if this works in v5?
The behavior is different in v5.
If this is a new deployment, I suggest starting with PGO v5
In v4, if you want the
pg_hba.confsettings to be applied at boostrap time, the section isbootstrap.pg_hba. You can then also have an entry in thepostgresql.pg_hbasection.
@jkatz I am looking to get this working in v5. I don't feel that the docs you linked to here are ver explicit on where I should be putting this in my configuration for v5. Could you provide an example? Thanks in advance.