Add security context for postgres (run as non-root)#135
Draft
Add security context for postgres (run as non-root)#135
Conversation
Gerrit91
commented
Nov 17, 2025
Gerrit91
commented
Nov 17, 2025
|
|
||
| // copyPostgresBinaries is needed to save old postgres binaries for a later major upgrade | ||
| func (db *Postgres) copyPostgresBinaries(ctx context.Context, override bool) error { | ||
| func (db *Postgres) copyPostgresBinaries(ctx context.Context, override bool) (string, error) { |
Contributor
Author
There was a problem hiding this comment.
getBinDir returns the path to /usr/local/bin from which init and upgrade commands cannot be executed. When executing them from the copied folder, it appears to work.
When copying the binaries the command does not fail but prints a warning that permission ownership cannot be preserved, which means that the contents from /usr/local/bin are copied to /data/postgres/pg-bin-v1x with ownership of postgres, which I think should be fine. Maybe we can even remove the os.Chown command this way.
Contributor
Author
There was a problem hiding this comment.
Yes, chown can go.
Gerrit91
commented
Nov 17, 2025
| PostgresUser = "postgres" | ||
|
|
||
| postgresContainerImage = "postgres:16-alpine" | ||
| postgresRunUser = int64(70) |
Contributor
Author
There was a problem hiding this comment.
This can probably be another number, too.
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.
Description
This is required for more restricted environments to allow starting with pod security standards.