Describe the bug
The Keycloak PostgreSQL Deployment mounts its data volume at the wrong path, so the PVC/emptyDir is never used by the library/postgres image. Database files are written to the container filesystem instead of the volume, which means Keycloak state is lost on pod restart/reschedule even when keycloak.persistent: true.
In operator/src/main/resources/k8s/keycloak-postgresql-deployment.yml:
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
volumeMounts:
- name: "keycloak-postgresql-data"
mountPath: "/var/lib/pgsql/data" # ❌ RHEL/SCL path
subPath: pgdata
- Default image is official
docker.io/library/postgres (e.g. 16.3-alpine)
PGDATA correctly targets /var/lib/postgresql/data/pgdata (Docker Hub postgres layout)
mountPath still uses /var/lib/pgsql/data (OpenShift/RHEL PostgreSQL layout)
Those paths do not overlap, so Postgres never sees the volume.
Expected behavior
Volume should be mounted under the official postgres data directory, matching PGDATA and the Helm chart:
mountPath: "/var/lib/postgresql/data"
subPath: pgdata
Reference (correct) in the main Microcks Helm chart:
https://github.com/microcks/microcks/blob/master/install/kubernetes/microcks/templates/deployment.yaml
(same PGDATA + mountPath: /var/lib/postgresql/data + subPath: pgdata)
How this likely happened
In #10 / microcks/microcks#1269, PGDATA and subPath: pgdata were added to address OpenShift chmod permission errors on the volume root, but mountPath was left at the old RHEL path. That can make the permission error disappear (data goes to writable container FS) while silently breaking persistence.
Impact
keycloak.persistent: true does not actually persist Keycloak DB data
- Pod restarts wipe users/realm state that was not re-imported
- Easy to miss in e2e if assertions only check pod readiness
Fix
Change mountPath from /var/lib/pgsql/data to /var/lib/postgresql/data.
I will open a PR with this one-line fix.
Environment
- Operator main @ de844f0
- Default keycloak postgres image:
docker.io/library/postgres:16.3-alpine (and earlier defaults also use library/postgres)
Describe the bug
The Keycloak PostgreSQL Deployment mounts its data volume at the wrong path, so the PVC/emptyDir is never used by the
library/postgresimage. Database files are written to the container filesystem instead of the volume, which means Keycloak state is lost on pod restart/reschedule even whenkeycloak.persistent: true.In
operator/src/main/resources/k8s/keycloak-postgresql-deployment.yml:docker.io/library/postgres(e.g.16.3-alpine)PGDATAcorrectly targets/var/lib/postgresql/data/pgdata(Docker Hub postgres layout)mountPathstill uses/var/lib/pgsql/data(OpenShift/RHEL PostgreSQL layout)Those paths do not overlap, so Postgres never sees the volume.
Expected behavior
Volume should be mounted under the official postgres data directory, matching
PGDATAand the Helm chart:Reference (correct) in the main Microcks Helm chart:
https://github.com/microcks/microcks/blob/master/install/kubernetes/microcks/templates/deployment.yaml
(same
PGDATA+mountPath: /var/lib/postgresql/data+subPath: pgdata)How this likely happened
In #10 / microcks/microcks#1269,
PGDATAandsubPath: pgdatawere added to address OpenShiftchmodpermission errors on the volume root, butmountPathwas left at the old RHEL path. That can make the permission error disappear (data goes to writable container FS) while silently breaking persistence.Impact
keycloak.persistent: truedoes not actually persist Keycloak DB dataFix
Change
mountPathfrom/var/lib/pgsql/datato/var/lib/postgresql/data.I will open a PR with this one-line fix.
Environment
docker.io/library/postgres:16.3-alpine(and earlier defaults also uselibrary/postgres)