fix: postgres 18+ OpenShift compatibility#31
Merged
Conversation
- 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PostgreSQL pod fails to start on OpenShift with two errors:
chmod: /var/run/postgresql: Operation not permitted— OpenShift runs containers as a random non-root UID, but thepostgres:18-alpineentrypoint tries tochmoddirectories without a pod-levelfsGroupsecurity context.PostgreSQL data in /var/lib/postgresql/data (unused mount/volume)— Docker imagepostgres:18+changed the data directory structure. Instead of mounting at/var/lib/postgresql/data, you now mount at/var/lib/postgresqland the image creates versioned subdirectories likedata-18/. See ChangePGDATAin 18+ to/var/lib/postgresql/MAJOR/dockerdocker-library/postgres#1259Fix
fsGroup: 7000pod-levelsecurityContext— OpenShiftchowns the mounted volume to GID 7000 (thepostgresgroup in Alpine), resolving the permission error.mountPathfrom/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 underdata-18/. You'll need to either:mv /var/lib/postgresql/data/* /var/lib/postgresql/Fresh deployments are unaffected.