Instead of doing a config map, I simply copy this file to another directory and run postgres with the configuration in the changed directory using -c config_file:
1 FROM postgres:latest
1 ARG VERSION
2
3 COPY deployment/postgres_init /docker-entrypoint-initdb.d
4 USER postgres
5 RUN initdb
6 CMD postgres -c hba_file=/docker-entrypoint-initdb.d/pg_hba.conf -c config_file=/docker-entrypoint-initdb.d/postgresql.conf
But now I see this error:
prikshetsharma@Prikshets-MacBook-Pro humboi % kubectl logs -f postgres-deployment-64cbffd6d8-r5wtn
2021-08-10 05:42:14.072 GMT [7] LOG: skipping missing configuration file "/var/lib/postgresql/data/postgresql.auto.conf"
2021-08-10 05:42:14.073 UTC [7] FATAL: data directory "/var/lib/postgresql/data" has wrong ownership
2021-08-10 05:42:14.073 UTC [7] HINT: The server must be started by the user that owns the data directory.
How to fix this?