Skip to content

Radius.Compute/containerImages type: add rootless BuildKit sidecar to dynamic-rp chart#11882

Draft
willdavsmith wants to merge 12 commits into
mainfrom
feat/containerimages-buildkit-sidecar
Draft

Radius.Compute/containerImages type: add rootless BuildKit sidecar to dynamic-rp chart#11882
willdavsmith wants to merge 12 commits into
mainfrom
feat/containerimages-buildkit-sidecar

Conversation

@willdavsmith
Copy link
Copy Markdown
Contributor

@willdavsmith willdavsmith commented May 13, 2026

Summary

Adds a rootless BuildKit sidecar to the dynamic-rp Pod so in-cluster Terraform recipes can build and push container images without a host Docker socket, a privileged Pod, or per-node host preparation.

The motivating consumer is the new Radius.Compute/containerImages resource type — see companion PR radius-project/resource-types-contrib#151.

What's in this PR

Scope is deliberately limited to the chart changes the BuildKit-backed recipe needs to function:

  • buildkitd sidecar container (rootless, listens on Pod loopback TCP 127.0.0.1:1234) added to the dynamic-rp Pod.
  • buildctl-init init container that copies the buildctl CLI into a shared emptyDir, mounted into the dynamic-rp container's PATH.
  • New dynamicrp.buildkit.* values surface: enabled (default true), psaMode (baseline default, restricted opt-in on K8s ≥ 1.30 with UserNamespacesSupport), image, resources.
  • helm-unittest cases for the buildkit sidecar shape (default-on / disabled).

Three files, +191 / -1. No Go code changes, no RBAC changes, no documentation changes.

Wave structure

This PR is Wave 1: the chart runtime piece the recipe needs to function end-to-end with git-context builds. It is independently reviewable and mergeable.

Wave 2 — follow-up PRs in this repo (none depend on Wave 1 being unmerged):

  • docs/contributing/.../buildkit-recipes.md — contributor doc explaining the sidecar + local-exec-via-buildctl recipe pattern.
  • NOTES.txt preflight surfacing Kubernetes ≥ 1.30 + UserNamespacesSupport required when psaMode=restricted is selected on an incompatible cluster.

Wave 3 — local context upload (depends on Wave 1):

  • New dynamic-rp endpoint accepting tarball uploads, staging the context in an emptyDir for the recipe to consume.
  • rad CLI local-path detection: when build.source is a local path, tar with .dockerignore honored and POST to dynamic-rp before recipe execution.
  • Recipe-side change in radius-project/resource-types-contrib to accept the staged context path.

Until Wave 3 lands, build.source is restricted to git::https://... URLs and absolute filesystem paths already available to the recipe runtime.

Notable details

  • Default enabled: true. The buildkit sidecar runs by default on a fresh install. Operators who don't want it can --set dynamicrp.buildkit.enabled=false.
  • PSA modes. psaMode=baseline (default) works on every supported Kubernetes version. psaMode=restricted requires Kubernetes ≥ 1.30 with UserNamespacesSupport (uses hostUsers: false).
  • No credentials in the chart. Registry credentials are a per-environment platform-engineer concern, materialized via a Radius.Security/secrets resource and read by the recipe via data "kubernetes_secret". Nothing is mounted at chart level.

Testing

  • helm-unittest passes (including new buildkit cases).
  • End-to-end multi-arch build + push validated in a separate demo repository.

Coordination

Companion PR: radius-project/resource-types-contrib#151 (resource type + recipe). They should land together; this one is reviewable independently.

Design: #11734.

Copilot AI review requested due to automatic review settings May 13, 2026 22:38
@willdavsmith willdavsmith requested review from a team as code owners May 13, 2026 22:38
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 13, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the deploy/Chart dynamic-rp deployment to optionally run a rootless BuildKit sidecar (default on) and adds supporting documentation/tests, enabling in-cluster image build/push scenarios without relying on a host Docker socket.

Changes:

  • Add dynamicrp.buildkit.* values and wire a buildkitd sidecar + buildctl-init init container into the dynamic-rp Deployment.
  • Fix Terraform pre-mount pathing in the chart and add a drift-guard helm-unittest to keep chart/runtime paths aligned.
  • Add operator-facing NOTES warnings plus new design/contributor docs for the subsystem.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/recipes/terraform/install.go Logs an INFO message when no pre-mounted Terraform binary is present (to aid diagnosis).
eng/design-notes/recipes/2026-04-container-images-resource-type.md Adds a design note for the containerImages resource type and how BuildKit is used.
docs/contributing/contributing-code/contributing-code-writing/buildkit-recipes.md Documents the chart’s BuildKit sidecar and the recipe authoring pattern it enables.
deploy/Chart/values.yaml Introduces the dynamicrp.buildkit values surface (enabled/psaMode/image/credentials/resources).
deploy/Chart/tests/helpers_test.yaml Adds helm-unittest coverage for BuildKit enable/disable and Terraform-path drift guard.
deploy/Chart/templates/NOTES.txt Adds install-time warnings for incompatible PSA mode / missing registry credentials.
deploy/Chart/templates/dynamic-rp/rbac.yaml Grants dynamic-rp RBAC permissions for batch Jobs.
deploy/Chart/templates/dynamic-rp/deployment.yaml Implements the terraform pre-mount fix and adds BuildKit containers/env/volumes.

Comment thread deploy/Chart/templates/dynamic-rp/deployment.yaml
Comment thread docs/contributing/contributing-code/contributing-code-writing/buildkit-recipes.md Outdated
Comment thread eng/design-notes/recipes/2026-04-container-images-resource-type.md Outdated
Comment thread deploy/Chart/templates/dynamic-rp/deployment.yaml
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 13, 2026

Unit Tests

    2 files  ±0    435 suites  ±0   7m 41s ⏱️ +14s
5 250 tests +3  5 248 ✅ +3  2 💤 ±0  0 ❌ ±0 
6 372 runs  +3  6 370 ✅ +3  2 💤 ±0  0 ❌ ±0 

Results for commit 1ad6836. ± Comparison against base commit fc4f38b.

♻️ This comment has been updated with latest results.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.94%. Comparing base (fc4f38b) to head (1ad6836).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11882      +/-   ##
==========================================
+ Coverage   51.90%   51.94%   +0.04%     
==========================================
  Files         732      732              
  Lines       46272    46305      +33     
==========================================
+ Hits        24016    24052      +36     
+ Misses      19957    19953       -4     
- Partials     2299     2300       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@willdavsmith willdavsmith marked this pull request as draft May 14, 2026 17:59
@willdavsmith willdavsmith force-pushed the feat/containerimages-buildkit-sidecar branch from 5df989d to 9d6ddfa Compare May 18, 2026 18:36
@willdavsmith willdavsmith changed the title Add optional rootless BuildKit sidecar to dynamic-rp chart Radius.Compute/containerImages type: add rootless BuildKit sidecar to dynamic-rp chart May 22, 2026
@willdavsmith willdavsmith force-pushed the feat/containerimages-buildkit-sidecar branch from 48b5a64 to 1f983a8 Compare May 28, 2026 20:18
@willdavsmith willdavsmith requested a review from Copilot May 29, 2026 18:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Adds an optional, rootless BuildKit sidecar to the dynamic-rp Pod that
in-cluster Terraform recipes can drive via the buildctl CLI to build
and push container images. Motivating consumer is the new
Radius.Compute/containerImages resource type in resource-types-contrib.

Chart additions (deploy/Chart):
- buildkitd sidecar container (rootless, no privileged Pod, no host
  Docker socket) with default-on enabled flag, configurable image,
  PSA mode (restricted/baseline), credentialsSecret, and resource
  limits/requests
- buildctl-init init container that mounts the buildctl CLI into the
  dynamic-rp container's PATH
- registry-credentials volume mounting an operator-supplied Secret at
  ~/.docker/config.json
- RBAC: batch/jobs access for recipe-spawned Jobs
- NOTES.txt warnings for misconfigured PSA mode and missing creds
- helm-unittest cases covering buildkit sidecar shape (default-on /
  disabled) and a drift-guard against the install.go path contract

Other changes:
- pkg/recipes/terraform/install.go: log INFO when no pre-mounted
  Terraform binary is present, naming the expected paths
- Fixes a path-mismatch bug in the chart's Terraform pre-mount init
  script (was writing to a directory the runtime never reads from)
- New contributor doc covering the buildkit subsystem and the
  local-exec recipe pattern
- Design doc copied to eng/design-notes/recipes/

Coordinates with resource-types-contrib PR for the resource type and
recipe.

Signed-off-by: willdavsmith <willdavsmith@gmail.com>
The containerImages recipe now reads registry credentials from a
per-resource Radius.Security/secrets resource via the kubernetes_secret_v1
data source, matching the mysql pattern. The chart no longer needs to
mount a Docker config.json — drop dynamicrp.buildkit.credentialsSecret
value, volume, and volumeMount. Update fsGroup comment to reflect the
buildctl binary mount (TCP, no socket sharing). Rewrite NOTES.txt to
point platform engineers at the recipe-registration flow. Add a helm
unittest covering the buildctl-init init container when terraform is
disabled. Spelling list additions for new tech terms.

Signed-off-by: willdavsmith <willdavsmith@gmail.com>
The previous default of `restricted` requires Kubernetes 1.30+ with
the UserNamespacesSupport feature gate, which is not available out of
the box on kind, k3d, Docker Desktop, or older managed clusters. This
forced almost every operator trying out the BuildKit sidecar to
immediately discover the failure mode and reinstall with
--set dynamicrp.buildkit.psaMode=baseline.

Flip the default so `rad install kubernetes` is a one-liner on every
supported Kubernetes version. Operators who enforce PSA restricted
cluster-wide and run a recent enough kernel can opt into the stricter
sidecar profile with --set dynamicrp.buildkit.psaMode=restricted; the
existing NOTES.txt preflight surfaces a clear remediation if it's
selected on an incompatible cluster.

Also update the NOTES.txt registry-credentials hint to reflect the
PE-owned dockerconfigjson Secret model rather than the developer-owned
Radius.Security/secrets language.

Signed-off-by: willdavsmith <willdavsmith@gmail.com>
The buildkit recipes contributing guide and the container-images
design note now live on the upstream PR branch; remove the demo
submodule copies. Drop unused cspell entries (Buildah, Kaniko,
binfmt, buildctl, buildkitd) since they no longer appear in any
file shipped by the submodule.

Signed-off-by: willdavsmith <willdavsmith@gmail.com>
…buildkit-sidecar

Signed-off-by: willdavsmith <willdavsmith@gmail.com>

# Conflicts:
#	deploy/Chart/templates/dynamic-rp/deployment.yaml
…buildkit-sidecar

Signed-off-by: willdavsmith <willdavsmith@gmail.com>
…kit branch)

Signed-off-by: willdavsmith <willdavsmith@gmail.com>
- deployment.yaml: the .Values.dynamicrp.resources block was checking
  dynamicrp but rendering rp.resources, so any dynamicrp-scoped
  resource overrides silently fell through to applications-rp's
  values. Render dynamicrp.resources to match the if-check.
- Tighten verbose multi-line comments around hostUsers, fsGroup,
  buildctl-init, env vars, the buildkitd sidecar header, and the
  PSA seccomp/AppArmor + newuidmap rationale. Preserve load-bearing
  comments (/terraform hardcode, pinned Terraform version,
  GLOBAL_DIR path duplication).
- values.yaml: trim verbose buildkit field docs.

Signed-off-by: willdavsmith <willdavsmith@gmail.com>
@willdavsmith willdavsmith force-pushed the feat/containerimages-buildkit-sidecar branch from e200448 to 5903352 Compare May 29, 2026 19:47
The containerImages recipe uses the in-pod BuildKit sidecar
(buildctl over the sidecar's socket); it does not create
Kubernetes Jobs, so this grant is unnecessary.

Signed-off-by: willdavsmith <willdavsmith@gmail.com>
Drop changes unrelated to the Radius.Compute/containerImages feature:
- NOTES.txt operator guidance (belongs in resource-type README)
- dynamicrp.resources rename in deployment.yaml (pre-existing chart
  bug, tracked separately)
- terraform binary-path drift-guard test (about install.go, not
  containerImages)

Signed-off-by: willdavsmith <willdavsmith@gmail.com>
Signed-off-by: willdavsmith <willdavsmith@gmail.com>
@willdavsmith willdavsmith requested a review from Copilot May 29, 2026 22:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread deploy/Chart/templates/dynamic-rp/deployment.yaml Outdated
HOME=/home/rpuser was set so buildctl could find a chart-mounted
~/.docker/config.json. That credentials-volume approach was dropped
in favor of a per-recipe Docker config written under the module path
with DOCKER_CONFIG set in the recipe's local-exec environment, so
dynamic-rp itself never reads $HOME/.docker/config.json. Remove the
env var to avoid implying credentials wiring that doesn't exist.

Signed-off-by: willdavsmith <willdavsmith@gmail.com>
@radius-functional-tests
Copy link
Copy Markdown

radius-functional-tests Bot commented May 29, 2026

Radius functional test overview

🔍 Go to test action run

Click here to see the test run details
Name Value
Repository radius-project/radius
Commit ref 1ad6836
Unique ID func68da25feeb
Image tag pr-func68da25feeb
  • gotestsum 1.13.0
  • KinD: v0.29.0
  • Dapr: 1.14.4
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-func68da25feeb
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-func68da25feeb
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-func68da25feeb
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-func68da25feeb
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-func68da25feeb
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting corerp-cloud functional tests...
⌛ Starting ucp-cloud functional tests...
✅ ucp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment on lines +41 to +47
{{- if .Values.dynamicrp.buildkit.enabled }}
# fsGroup 65532 lets the dynamic-rp container (UID 65532) read
# the buildctl binary copied into the shared emptyDir by the
# buildctl-init init container.
securityContext:
fsGroup: 65532
{{- end }}
Comment on lines +200 to +202
# buildctl lives in the mounted emptyDir.
- name: PATH
value: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/buildctl"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants