Skip to content

Honor container registries in published Kubernetes charts - #21121

Merged
Mitch Denny (mitchdenny) merged 1 commit into
mainfrom
mitchdenny-kubernetes-container-registry
Oct 21, 2026
Merged

Mitch Denny (mitchdenny) merged 1 commit into
mainfrom
mitchdenny-kubernetes-container-registry

Conversation

@mitchdenny

@mitchdenny Mitch Denny (mitchdenny) commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Description

Published Kubernetes charts currently use <resource>:latest for buildable images even when a container registry is configured. Deploying those charts directly with Helm can therefore fail to pull the intended image.

Resolve registry-qualified image defaults during publication when the registry endpoint and repository are literal values or non-secret parameters with defaults. Reuse ContainerImageReference so repository prefixes, explicit registry selection, and custom image push names/tags follow the existing deployment naming rules. Preserve deferred registry inputs for deployment-time resolution and leave prebuilt container images unchanged.

Add publisher snapshots and regression coverage for explicit/default registries, custom image names/tags, parameter defaults, missing and secret parameters, deferred outputs, Dockerfile-backed resources, and deployment-time overrides. Update the Kubernetes README to explain publication versus deployment resolution. No new dependencies or public APIs.

Fixes #14011

User-facing usage

C# AppHost:

var registry = builder.AddContainerRegistry("registry", "registry.example.com", "apps");
builder.AddProject<Projects.Api>("api")
    .WithContainerRegistry(registry);

TypeScript AppHost:

const registry = await builder.addContainerRegistry("registry", "registry.example.com", "apps");
const api = await builder.addNodeApp("api", "../api", "server.js");
await api.withContainerRegistry(registry);

Running aspire publish now produces this image value instead of api:latest:

parameters:
  api:
    api_image: "registry.example.com/apps/api:latest"

Registry outputs that require provisioning remain deferred. When deploying the published chart outside aspire deploy, supply those deferred image values to Helm.

Validation

The original regression was reproduced locally before the fix: expected registry.example.com/apps/api:latest, actual api:latest.

Passed: 170 tests, with reviewed generated snapshots, at head 15321d211d6614ec5c72b61f4750b480af88453f:

dotnet test --project tests/Aspire.Hosting.Kubernetes.Tests/Aspire.Hosting.Kubernetes.Tests.csproj --no-launch-profile -- --filter-class "*.KubernetesPublisherTests" --filter-class "*.KubernetesDeployTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"

Passed: four fresh-AppHost publishing scenarios on macOS ARM64 using the exact-head PR CLI and packages, version 17.0.0-pr.21121.g15321d21, from CI artifacts. Each scenario generated charts and passed complete structured assertions on image parameters and Helm-rendered workload images:

Scenario Result
Literal registry qualification; prebuilt image unchanged Passed
Explicit registry precedence; custom image path/tag; fully-qualified override Passed
Published parameter defaults; missing and secret registry inputs remain deferred Passed
No registry configured preserves existing defaults Passed

Commands run for each scenario after creating a fresh aspire-empty C# AppHost from the PR hive, adding the matching Kubernetes integration, and creating a net10.0 API project:

"$cli" publish --apphost "$app/apphost.cs" --output-path "$app/output" --non-interactive --include-exception-details
python3 "$evidence/assert_publish.py" "$app/output" "$images" "$parameters"
helm template registry-smoke "$chart"

All commands passed. The missing-input scenario emitted the expected existing parameter-processing warning, then published successfully with the image placeholder retained. No live Kubernetes deployment or registry push was performed. Overall CI was still running when local validation completed.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 4112a489-7890-4a18-a965-664f81b553ea
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21121

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21121"

@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

5 / 99 PR test projects · 2 PR jobs, from 26 changed files.

Selected PR test projects (5 / 99)

Aspire.Cli.EndToEnd.Tests, Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Docker.Tests, Aspire.Hosting.Kubernetes.Tests

Selected PR jobs (2)

polyglot, typescript-api-compat


How these were chosen — grouped by what changed

🔧 src/Aspire.Hosting.Kubernetes/Deployment/HelmDeploymentEngine.cs (changed source)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests
→ 3 via the project graph: Aspire.Hosting.Azure.Kubernetes.Tests (2 hops), Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Docker.Tests

📦 affected project Aspire.Hosting.Kubernetes
→ 1 test: Aspire.Cli.EndToEnd.Tests

🔧 src/Aspire.Hosting.Kubernetes/KubernetesPublishingContext.cs (changed source)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/KubernetesPublisherTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishDefersContainerRegistryOutputs_repositoryOutput=False.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishDefersContainerRegistryOutputs_repositoryOutput=True.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishDefersContainerRegistryParameters_repositoryParameter=False_secret=False#00.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishDefersContainerRegistryParameters_repositoryParameter=False_secret=False#01.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishDefersContainerRegistryParameters_repositoryParameter=False_secret=True#00.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishDefersContainerRegistryParameters_repositoryParameter=False_secret=True#01.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishDefersContainerRegistryParameters_repositoryParameter=True_secret=False#00.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishDefersContainerRegistryParameters_repositoryParameter=True_secret=False#01.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishDefersContainerRegistryParameters_repositoryParameter=True_secret=True#00.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishDefersContainerRegistryParameters_repositoryParameter=True_secret=True#01.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishDefersMissingContainerRegistryParameters_repositoryParameter=False.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishDefersMissingContainerRegistryParameters_repositoryParameter=True.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishDefersSecretContainerRegistryDefaults.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishUsesConfiguredContainerRegistry_explicitRegistry=False_customizeImage=False#00.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishUsesConfiguredContainerRegistry_explicitRegistry=False_customizeImage=False#01.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishUsesConfiguredContainerRegistry_explicitRegistry=True_customizeImage=False#00.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishUsesConfiguredContainerRegistry_explicitRegistry=True_customizeImage=False#01.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishUsesConfiguredContainerRegistry_explicitRegistry=True_customizeImage=True#00.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishUsesConfiguredContainerRegistry_explicitRegistry=True_customizeImage=True#01.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishUsesContainerRegistryForDockerfileWithoutChangingPrebuiltImages#00.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishUsesContainerRegistryForDockerfileWithoutChangingPrebuiltImages#01.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishUsesContainerRegistryForDockerfileWithoutChangingPrebuiltImages#02.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Kubernetes.Tests/Snapshots/KubernetesPublisherTests.PublishUsesContainerRegistryParameterDefaults.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

Job reasons

Job Triggered by
polyglot • affected project Aspire.Hosting.Kubernetes
• affected project Aspire.Hosting.Azure.Provisioning.ContainerService
typescript-api-compat affected project Aspire.Hosting.Kubernetes

Selection computed for commit 15321d2.

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.

🟡 Changes recommended

Eager image-push callbacks can abort publication when their inputs are available only during deployment.

1 open issue
What changed in this PR

Addresses #14011 by including configured container registries in published Kubernetes chart image defaults.

Changes:

  • Resolves publish-safe registry values using existing image naming rules.
  • Adds regression tests and snapshots for registry selection, customization, and deferred inputs.
  • Documents publication versus deployment resolution.
File Description
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishUsesContainerRegistryParameterDefaults.verified.yaml Parameter-default image snapshot.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishUsesContainerRegistryForDockerfileWithoutChangingPrebuiltImages#02.verified.yaml Unchanged prebuilt image.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishUsesContainerRegistryForDockerfileWithoutChangingPrebuiltImages#01.verified.yaml Dockerfile deployment template.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishUsesContainerRegistryForDockerfileWithoutChangingPrebuiltImages#00.verified.yaml Qualified Dockerfile image.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishUsesConfiguredContainerRegistry_explicitRegistry=True_customizeImage=True#01.verified.yaml Customized-image deployment template.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishUsesConfiguredContainerRegistry_explicitRegistry=True_customizeImage=True#00.verified.yaml Custom image name and tag.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishUsesConfiguredContainerRegistry_explicitRegistry=True_customizeImage=False#01.verified.yaml Explicit-registry deployment template.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishUsesConfiguredContainerRegistry_explicitRegistry=True_customizeImage=False#00.verified.yaml Explicit-registry image value.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishUsesConfiguredContainerRegistry_explicitRegistry=False_customizeImage=False#01.verified.yaml Default-registry deployment template.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishUsesConfiguredContainerRegistry_explicitRegistry=False_customizeImage=False#00.verified.yaml Default-registry image value.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishDefersSecretContainerRegistryDefaults.verified.yaml Secret-default placeholder.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishDefersMissingContainerRegistryParameters_repositoryParameter=True.verified.yaml Missing-repository placeholder.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishDefersMissingContainerRegistryParameters_repositoryParameter=False.verified.yaml Missing-endpoint placeholder.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishDefersContainerRegistryParameters_repositoryParameter=True_secret=True#01.verified.yaml Secret repository deployment resolution.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishDefersContainerRegistryParameters_repositoryParameter=True_secret=True#00.verified.yaml Secret repository publication placeholder.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishDefersContainerRegistryParameters_repositoryParameter=True_secret=False#01.verified.yaml Repository parameter deployment resolution.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishDefersContainerRegistryParameters_repositoryParameter=True_secret=False#00.verified.yaml Repository parameter publication placeholder.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishDefersContainerRegistryParameters_repositoryParameter=False_secret=True#01.verified.yaml Secret endpoint deployment resolution.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishDefersContainerRegistryParameters_repositoryParameter=False_secret=True#00.verified.yaml Secret endpoint publication placeholder.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishDefersContainerRegistryParameters_repositoryParameter=False_secret=False#01.verified.yaml Endpoint parameter deployment resolution.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishDefersContainerRegistryParameters_repositoryParameter=False_secret=False#00.verified.yaml Endpoint parameter publication placeholder.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishDefersContainerRegistryOutputs_repositoryOutput=True.verified.yaml Deferred repository-output placeholder.
tests/​Aspire.Hosting.Kubernetes.Tests/​Snapshots/​KubernetesPublisherTests.PublishDefersContainerRegistryOutputs_repositoryOutput=False.verified.yaml Deferred endpoint-output placeholder.
tests/​Aspire.Hosting.Kubernetes.Tests/​KubernetesPublisherTests.cs Registry publication regression coverage.
src/​Aspire.Hosting.Kubernetes/​README.md Explains registry resolution and overrides.
src/​Aspire.Hosting.Kubernetes/​KubernetesPublishingContext.cs Resolves publish-time image defaults.
src/​Aspire.Hosting.Kubernetes/​Deployment/​HelmDeploymentEngine.cs Updates deployment-resolution comments only.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment tests starting on PR #21121...

This will deploy to real Azure infrastructure. Results will be posted here when complete.

View workflow run

@mitchdenny
Mitch Denny (mitchdenny) merged commit ffe52b3 into main Oct 21, 2026
168 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.0 milestone Oct 21, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #1935

Generated by PR Documentation Check · copilot · auto · 32.9 AIC · ⌖ 1.17 AIC · ⊞ 20.4K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#1935 targeting release/17.0.

Added a "Container registries and published images" section to deployment/kubernetes.mdx. Triggered signals: integration_readme_changed (Kubernetes README), pr_body_has_user_facing_section and pr_body_has_cli_flag_mention (the PR body's usage and aspire publish examples).

Note

This draft PR needs human review before merging.

Mitch Denny (mitchdenny) added a commit to microsoft/aspire.dev that referenced this pull request Nov 17, 2026
…rts (#1935)

Documents changes from microsoft/aspire#21121 by ``@davidfowl-unknown``

**Target branch:** Targeting `release/17.0` based on the source PR
milestone `17.0` (`exact_match`).

## Why
The source PR makes `aspire publish` write registry-qualified image
values (for example `registry.example.com/apps/api:latest`) into
published Kubernetes Helm charts. Previously the value was `api:latest`.
Resolution of deferred registry inputs happens at deploy time. The docs
didn't cover this.

Triggered signals: `integration_readme_changed`,
`pr_body_has_user_facing_section`, `pr_body_has_cli_flag_mention`.

## Changes
Updated an existing page:
- `src/frontend/src/content/docs/deployment/kubernetes.mdx`: added a
"Container registries and published images" section with C# and
TypeScript examples, the published `values.yaml` result, and
publish-time vs deploy-time resolution.

> Generated by [PR Documentation
Check](https://github.com/microsoft/aspire/actions/runs/39547952513) for
#21121 · copilot · auto · 32.9 AIC · ⌖ 1.17 AIC · ⊞ 20.4K ·
[◷](https://github.com/search?q=repo%3Amicrosoft%2Faspire.dev+%22gh-aw-workflow-id%3A+pr-docs-check%22&type=pullrequests)

<!-- gh-aw-agentic-workflow: PR Documentation Check, engine: copilot,
model: auto, id: 39547952513, workflow_id: pr-docs-check, run:
https://github.com/microsoft/aspire/actions/runs/39547952513 -->

<!-- gh-aw-workflow-id: pr-docs-check -->
<!-- gh-aw-workflow-call-id: microsoft/aspire/pr-docs-check -->
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 20, 2026

This branch was previously deployed

1 inactive deployment
deployment-testing — 15321d21 Deployed Oct 19, 2026 by mitchdenny via Deploy (Deployment.EndToEnd-AksStarterDeploymentTests) #893
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.WithContainerRegistry has no effect when deploying to Kubernetes

3 participants