Skip to content

Add security context for postgres (run as non-root)#135

Draft
Gerrit91 wants to merge 5 commits intomasterfrom
postgres-security-context
Draft

Add security context for postgres (run as non-root)#135
Gerrit91 wants to merge 5 commits intomasterfrom
postgres-security-context

Conversation

@Gerrit91
Copy link
Contributor

Description

This is required for more restricted environments to allow starting with pod security standards.

@metal-robot metal-robot bot added the area: control-plane Affects the metal-stack control-plane area. label Nov 14, 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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, chown can go.

PostgresUser = "postgres"

postgresContainerImage = "postgres:16-alpine"
postgresRunUser = int64(70)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be another number, too.

@Gerrit91 Gerrit91 changed the title Add security context for postgres. Add security context for postgres (run as non-root) Nov 17, 2025
@Gerrit91 Gerrit91 added the area: compliance Affects the compliance area. label Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: compliance Affects the compliance area. area: control-plane Affects the metal-stack control-plane area.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant