Skip to content

fix: move the operator image to Azure Linux distroless - #525

Merged
guanzhousongmicrosoft merged 4 commits into
documentdb:mainfrom
guanzhousongmicrosoft:developer/guanzhou/operator-distroless-base
Nov 24, 2026
Merged

guanzhousongmicrosoft merged 4 commits into
documentdb:mainfrom
guanzhousongmicrosoft:developer/guanzhou/operator-distroless-base

Conversation

@guanzhousongmicrosoft

@guanzhousongmicrosoft guanzhousongmicrosoft commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Every operator release (1.0.0 to 1.2.1) is built on mcr.microsoft.com/devcontainers/base:alpine, so the image carries a full dev container userland (OpenSSH client, BusyBox, bash, zsh, apk, sudo, git) at 838–851 MB. Scanners now flag it for SSHole (CVE-2026-123158). The image has only the OpenSSH client and never runs sshd, so it is not exploitable, but future CVEs in any of those packages would flag it the same way.

The apk upgrade added in 1.1.1 doesn't fix that: it helps only after Alpine ships a fix, and keeps packages the operator never uses. The manager is a static Go binary that needs only CA certificates, tzdata and /tmp, so the runtime stage moves to mcr.microsoft.com/azurelinux/distroless/minimal:3.0 (5 packages, no shell or package manager, 93–98 MB). It keeps uid/gid 100:101, so the chart's pinned runAsUser/runAsGroup and --reuse-values upgrades still work. kubectl exec into the operator pod no longer has a shell; use kubectl debug.

assert-minimal-image.sh fails the build if the image ships an SSH binary, a shell or a package manager (PR CI for the operator, the candidate build for operator and sidecar). It matches by file name, so it catches a distro base coming back, not a renamed binary. Against the released 1.2.1 image it fails, listing ssh, scp, sftp, ssh-agent, bash, zsh, busybox and apk among others.

The build summary echoes in test-build-and-package.yml are grouped into one redirect because the workflow linter reports every line of a changed file, and that block's SC2129 failed it.

Signed-off-by: Guanzhou Song <85122868+guanzhousongmicrosoft@users.noreply.github.com>
Signed-off-by: Guanzhou Song <85122868+guanzhousongmicrosoft@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the runtime-image hardening change.

No open issues 🎉

What changed in this PR

Moves the operator runtime from an Alpine development container to Azure Linux distroless, reducing unnecessary packages while preserving the existing UID/GID for Helm upgrade compatibility.

Changes:

  • Replaces the runtime base image while retaining USER 100:101.
  • Adds image-content checks and test fixtures to reject SSH tools, shells, and package managers.
  • Integrates checks into build workflows and documents using kubectl debug for troubleshooting.
File Description
operator/​src/​Dockerfile Switches to Azure Linux distroless and preserves UID/GID.
operator/​documentdb-helm-chart/​values.yaml Updates security-context comments; values remain unchanged.
CHANGELOG.md Documents the security change and shell-free troubleshooting.
.github/​workflows/​test-e2e.yml Adds image-check scripts to workflow path triggers.
.github/​workflows/​test-build-and-package.yml Runs check-script tests and validates operator images.
.github/​workflows/​build_operator_images.yml Checks candidate operator and sidecar images before pushing.
.github/​scripts/​assert-minimal-image.sh Rejects images containing prohibited runtime tools.
.github/​scripts/​assert-minimal-image_test.sh Adds clean and prohibited-file image fixtures to test the check.

Review effort: Balanced

Signed-off-by: Guanzhou Song <85122868+guanzhousongmicrosoft@users.noreply.github.com>
Signed-off-by: Guanzhou Song <85122868+guanzhousongmicrosoft@users.noreply.github.com>
@documentdb-triage-tool documentdb-triage-tool Bot added CI/CD documentation Improvements or additions to documentation labels Nov 24, 2026
@documentdb-triage-tool

Copy link
Copy Markdown

🤖 Auto-triaged by documentdb-triage-tool.

Applied: CI/CD, documentation
Project fields suggested: Component ci · Priority P0 · Effort L · Status Ready
Confidence: 0.95 (deterministic)

Reasoning

component from path globs (ci, docs); P0 keyword "cve" in body; effort from diff stats (142+28 LOC, 9 files)

If a label is wrong, ping @patty-chow so the rules can be tuned. Issues with component labels are left alone; PR component labels are reconciled from changed paths on every run.

@guanzhousongmicrosoft
guanzhousongmicrosoft merged commit be57582 into documentdb:main Nov 24, 2026
65 of 66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI/CD documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants