Skip to content

fix: postgres 18+ OpenShift compatibility#31

Merged
syangsao merged 1 commit into
mainfrom
fix/openshift-postgres-18-compatibility
May 21, 2026
Merged

fix: postgres 18+ OpenShift compatibility#31
syangsao merged 1 commit into
mainfrom
fix/openshift-postgres-18-compatibility

Conversation

@syangsao
Copy link
Copy Markdown
Owner

Problem

PostgreSQL pod fails to start on OpenShift with two errors:

  1. chmod: /var/run/postgresql: Operation not permitted — OpenShift runs containers as a random non-root UID, but the postgres:18-alpine entrypoint tries to chmod directories without a pod-level fsGroup security context.

  2. PostgreSQL data in /var/lib/postgresql/data (unused mount/volume) — Docker image postgres:18+ changed the data directory structure. Instead of mounting at /var/lib/postgresql/data, you now mount at /var/lib/postgresql and the image creates versioned subdirectories like data-18/. See Change PGDATA in 18+ to /var/lib/postgresql/MAJOR/docker docker-library/postgres#1259

Fix

  • Added fsGroup: 7000 pod-level securityContext — OpenShift chowns the mounted volume to GID 7000 (the postgres group in Alpine), resolving the permission error.
  • Changed mountPath from /var/lib/postgresql/data/var/lib/postgresql — matches the new volume structure for postgres:18+ images.

Notes

If you have an existing PVC with data, the old data lives under data/ on the volume. Postgres 18+ expects it under data-18/. You'll need to either:

  • Move the data: mv /var/lib/postgresql/data/* /var/lib/postgresql/
  • Or delete and recreate the PVC (loses data)

Fresh deployments are unaffected.

- Add fsGroup security context to fix 'chmod: Operation not permitted'
  error caused by OpenShift running containers as random non-root UID
- Change mountPath from /var/lib/postgresql/data to /var/lib/postgresql
  to match Docker image postgres:18+ volume structure change
  (docker-library/postgres#1259)
@syangsao syangsao merged commit 0787cfd into main May 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant