Skip to content

fix: Ship a nonroot user in the scratch image - #33

Merged
ecv merged 1 commit into
mainfrom
fix/scratch-nonroot-user
Nov 7, 2026
Merged

ecv merged 1 commit into
mainfrom
fix/scratch-nonroot-user

Conversation

@ecv

@ecv ecv commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Every new service starts from this template, so each one inherits a scratch image that runs with group 0 and can't read its cert-manager certificate.

A scratch image has no /etc/passwd, so on our clusters the container starts as uid 65532 but gid 0, even though the image says USER 65532:65532. The cert-manager CSI client certificate is mounted with fs-group: 65532, so the process can't read it and crash-loops. This is what took staging down on 21 October (network-services-operator#685, datum#312). Docker on a laptop doesn't reproduce it, because Docker honours the group.

This writes a minimal nonroot user and group (65532) in the builder stage and copies /etc/passwd and /etc/group into the scratch image. Root CAs are unaffected: the binary already embeds them through x509roots/fallback.

Related to datum-cloud/infra#7436, closes #27 once proven in staging.

Test plan

  • Local build: image carries /etc/passwd and /etc/group with nonroot:65532, user 65532:65532
  • CI green

A scratch image has no /etc/passwd, so the kubelet starts the container
as uid 65532 but gid 0 despite USER 65532:65532. The cert-manager CSI
client certificate is mounted with fs-group 65532, so the process cannot
read it and crashes at startup. Docker on a laptop honours the group and
does not reproduce this.

Key changes:
- Write a minimal /etc/passwd and /etc/group for nonroot (65532) in the
  builder stage and copy them into the runtime image

Related to datum-cloud/infra#7436
@ecv
ecv force-pushed the fix/scratch-nonroot-user branch from 1c706e0 to b309078 Compare November 6, 2026 16:10
@ecv
ecv marked this pull request as ready for review November 6, 2026 16:13
@ecv
ecv requested a review from a team as a code owner November 6, 2026 16:13
@ecv
ecv requested review from kevwilliams and scotwells November 6, 2026 16:13
@ecv
ecv merged commit 7afcbbe into main Nov 7, 2026
5 checks passed
@ecv
ecv deleted the fix/scratch-nonroot-user branch November 7, 2026 14:31
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.

Build the Go image from scratch instead of Debian

2 participants