Postgres for Keycloak → "error: directory "/var/lib/postgresql/data" exists but is not empty"
keycloak-postgresql pod keeps crashing due to the following error:
"error: directory "/var/lib/postgresql/data" exists but is not empty"
This error seems to occur when the mount point directory of the PVC is used for database data. PostgreSQL initialization will keep failing.
Solution: Add the following environment variable to keycloak/postgresql-statefulset.yaml (this adds a subdirectory for PostgreSQL to store its data):
env:
- name: PGDATA
value: /var/lib/postgresql/data/db-files