Skip to content

Validate Helm CLI version (>= 4.2.0) before Kubernetes deploy#17491

Merged
mitchdenny merged 7 commits into
mainfrom
mitchdenny/issue-16977-validate-helm-is-installed-and-assert-co-a823a9
May 27, 2026
Merged

Validate Helm CLI version (>= 4.2.0) before Kubernetes deploy#17491
mitchdenny merged 7 commits into
mainfrom
mitchdenny/issue-16977-validate-helm-is-installed-and-assert-co-a823a9

Conversation

@mitchdenny
Copy link
Copy Markdown
Member

Description

Aspire's Kubernetes deployment pipeline shells out to helm upgrade --install for the main application chart and any AddHelmChart(...) resources on a KubernetesEnvironmentResource. Previously we only checked that helm was on PATH; we never asserted the installed version was new enough for the flags and behaviors we depend on (notably the Helm 4 form of --server-side=true --force-conflicts). Missing or old Helm produced confusing low-level errors like unknown flag: --force-conflicts, Flag --force has been deprecated, or raw process-spawn failures.

This PR adds an up-front version assertion of Helm 4.2.0+ (the latest stable at the time of writing) and turns those cryptic failures into a single clear, actionable error.

Approach

  • Added an internal HelmVersionValidator that runs helm version --short --client through the existing IHelmRunner abstraction, parses the SemVer (v?MAJOR.MINOR.PATCH, ignoring +gitsha build metadata), and asserts the minimum. Failures include the detected version, the required version, and a link to https://helm.sh/docs/intro/install/.
  • Wired the validator into the existing check-helm-prereqs-{env} pipeline step in HelmDeploymentEngine. One check per environment covers both the engine's main chart deploy and AddHelmChart(...) flows since they all DependsOn this step.
  • Updated the "Helm CLI not found" message to also call out the minimum version requirement.
  • Removed the now-redundant ad-hoc helm version --short probe at the top of HelmDeployAsync (the prereq step covers it with a much better error).
  • Promoted FakeHelmRunner from a private test class into a shared test helper that emits canned helm version stdout (defaults to v4.2.0+gfa15ec0) so any test exercising the deploy path automatically passes the new prereq check.
  • Documented the Helm 4.2.0+ requirement in the Aspire.Hosting.Kubernetes and Aspire.Hosting.Azure.Kubernetes READMEs.

Notes for reviewers

  • The kubectl-version question from the issue is intentionally out of scope (issue listed it as an open question).
  • No opt-out env var. We can add one later if user feedback warrants it.
  • Pipeline-level integration tests for the prereq step weren't added because check-helm-prereqs-{env} uses the real PathLookupHelper.FindFullPathFromPath("helm") and would behave nondeterministically based on whether helm happens to be installed on the test machine. The validator itself has 18 unit tests covering parsing, threshold behavior, and error message content.

Fixes #16977

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

Aspire's Kubernetes deployment pipeline shells out to 'helm upgrade --install'
for the main application chart and for any AddHelmChart(...) resources on a
KubernetesEnvironmentResource. Previously we only checked that 'helm' was on
PATH; we never asserted the installed Helm version was new enough for the
flags and behaviors we depend on (e.g. '--server-side=true --force-conflicts'
in the Helm 4 form). Missing or older Helm produced confusing low-level
errors like 'unknown flag: --force-conflicts', 'Flag --force has been
deprecated', or raw process-spawn failures.

Changes:

* Add internal HelmVersionValidator that runs 'helm version --short --client',
  parses the SemVer, and asserts a minimum of Helm 4.2.0. Throws a clear
  actionable InvalidOperationException (detected vs required + link to
  https://helm.sh/docs/intro/install/) when the version is too old,
  unparseable, or the command fails.
* Wire the validator into the existing check-helm-prereqs-{env} pipeline
  step in HelmDeploymentEngine. One check per environment covers both the
  main chart deploy and AddHelmChart(...) flows since they all DependsOn this
  step.
* Update the 'Helm CLI not found' message to also mention the minimum
  version requirement.
* Remove the now-redundant ad-hoc 'helm version --short' probe at the top of
  HelmDeployAsync (the prereq step covers it with a much better error).
* Promote FakeHelmRunner to a file-scoped test helper that emits canned
  'helm version' stdout (defaults to v4.2.0+gfa15ec0) and supports a
  separate VersionExitCode, so any test exercising the deploy path
  automatically passes the prereq check.
* Add HelmVersionValidatorTests covering: SemVer parsing of v3/v4/v5 outputs
  with and without '+gitsha' build metadata, rejection of unparseable
  output, threshold behavior for too-old versions (v4.1.0, v4.0.0, v3.18.0,
  v3.14.4), and that error messages include the detected version, the
  required version, and the install docs URL.
* Document the Helm 4.2.0+ requirement in the Aspire.Hosting.Kubernetes and
  Aspire.Hosting.Azure.Kubernetes READMEs.

Fixes #16977

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 26, 2026 04:54
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

🚀 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 -- 17491

Or

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

@davidfowl
Copy link
Copy Markdown
Contributor

Not for this PR but we have a whole system for this in run mode, I wonder if we can reuse it IRequiredCommandValidator

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 adds an explicit Helm CLI minimum-version check to Aspire’s Kubernetes deployment pipeline so users get a single actionable error when Helm is missing or too old, instead of confusing flag/spawn failures during helm upgrade --install.

Changes:

  • Added HelmVersionValidator and wired it into the per-environment check-helm-prereqs-{env} pipeline step.
  • Added unit tests for version parsing/threshold behavior and promoted FakeHelmRunner into a reusable test helper.
  • Documented the Helm v4.2.0+ prerequisite in the Kubernetes hosting READMEs.
Show a summary per file
File Description
tests/Aspire.Hosting.Kubernetes.Tests/KubernetesDeployTests.cs Removes the inline FakeHelmRunner in favor of a shared helper.
tests/Aspire.Hosting.Kubernetes.Tests/HelmVersionValidatorTests.cs Adds unit coverage for parsing + minimum-version enforcement behavior.
tests/Aspire.Hosting.Kubernetes.Tests/FakeHelmRunner.cs Introduces a shared in-memory IHelmRunner for tests with canned helm version output.
src/Aspire.Hosting.Kubernetes/README.md Adds Helm v4.2.0+ as a documented prerequisite.
src/Aspire.Hosting.Kubernetes/Deployment/HelmVersionValidator.cs Implements Helm version probing/parsing and minimum-version enforcement.
src/Aspire.Hosting.Kubernetes/Deployment/HelmDeploymentEngine.cs Runs the prereq check once per environment and removes the old ad-hoc probe from the deploy step.
src/Aspire.Hosting.Azure.Kubernetes/README.md Adds Helm v4.2.0+ as a documented prerequisite for AKS deploy flows.

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 5

Comment thread src/Aspire.Hosting.Kubernetes/Deployment/HelmVersionValidator.cs
Comment thread src/Aspire.Hosting.Kubernetes/Deployment/HelmVersionValidator.cs Outdated
Comment thread src/Aspire.Hosting.Kubernetes/Deployment/HelmDeploymentEngine.cs
Comment thread src/Aspire.Hosting.Kubernetes/README.md Outdated
Comment thread src/Aspire.Hosting.Azure.Kubernetes/README.md Outdated
The validator was invoking 'helm version --short --client', but the
--client flag was removed in Helm 4 (it existed in Helm 2 for the
real client/server split, was kept as a no-op in Helm 3, and is
unknown in Helm 4). Since this validator's purpose is to enforce
Helm 4.2.0 or later, passing --client guarantees a failure against
the very minimum version we require, surfacing the exact kind of
confusing prereq error this step exists to prevent.

Caught by dogfood testing of PR #17491 against a local Helm 4.2.0
install, which produced:

  Step 'check-helm-prereqs-k8s' failed: 'helm version --short --client'
  failed (Error: unknown flag: --client). Aspire requires Helm 4.2.0
  or later.

Switch to 'helm version --short', which produces identical output
shape (e.g. v4.2.0+gfa15ec0) on Helm 3 and Helm 4. Add a regression
test that records the arguments passed to the runner and asserts
--client is never included.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mitchdenny
Copy link
Copy Markdown
Member Author

PR Testing Report — #17491

PR Information

CLI Version Verification

  • Expected commit: 3a088b9e
  • Installed CLI reported: 13.4.0-pr.17491.g3a088b9e
  • Status: ✅ Verified

Changes Analyzed

  • src/Aspire.Hosting.Kubernetes/Deployment/HelmVersionValidator.cs (new)
  • src/Aspire.Hosting.Kubernetes/Deployment/HelmDeploymentEngine.cs (extended check-helm-prereqs-{env}; removed duplicate ad-hoc probe)
  • READMEs updated for hosting + Azure hosting Kubernetes packages
  • New FakeHelmRunner shared helper + HelmVersionValidatorTests (18 tests)

Test Scenarios Executed

Scenario 1 — End-to-end aspire deploy against a Kubernetes-targeted AppHost (happy-path expectation)

Objective: Confirm the new prereq step runs on a real deploy and lets a valid Helm install through.

Setup:

  • aspire new aspire-empty-generated AppHost wired with AddKubernetesEnvironment("k8s") + a container WithComputeEnvironment(k8s).
  • Local Helm: v4.2.0+g0646808 (the documented minimum).

Status:Failed — bug found

Observed output:

Step 'check-helm-prereqs-k8s' failed: 'helm version --short --client'
failed (Error: unknown flag: --client). Aspire requires Helm 4.2.0
or later. See https://helm.sh/docs/intro/install/.

Root cause: The validator invoked helm version --short --client. The --client flag existed in Helm 2 (real client/server split), was kept as a no-op in Helm 3, and was removed in Helm 4 — i.e. the very minimum version this validator enforces. The validator therefore guaranteed a failure on the supported floor, surfacing exactly the kind of confusing prereq error this step exists to prevent.

Scenario 2 — Regression coverage (unhappy-path)

Objective: Lock in the no---client invariant so this can't regress silently.

Status: ✅ Added EnsureMinimumVersionAsync_DoesNotPassClientFlag, which records the arguments passed to IHelmRunner and asserts --client is never present. All 19 validator tests + 254 K8s tests pass.

Fix Pushed

Commit ced45a67 on the PR branch:

  • Drop --client from the invocation (helm version --short produces the same vMAJOR.MINOR.PATCH+gSHA output on Helm 3 and Helm 4).
  • Update XML docs and the three error messages that referenced the old invocation.
  • Add the regression test above.

Summary

Scenario Status Notes
1 — aspire deploy w/ Helm 4.2.0 (happy path) ❌ Failed on 3a088b9e --client flag removed in Helm 4
2 — Regression test (no --client ever) ✅ Added Locks invariant

Overall Result

❌ Issue found and fixed in-PR. A re-dogfood of the updated PR head (ced45a67) is needed to confirm the deploy now proceeds past check-helm-prereqs-k8s on Helm 4.2.0.

Three review items from the automated PR reviewer:

1. Gate destroy/uninstall on the same Helm prereq check as deploy.
   Both 'destroy-helm-{env}' and 'helm-uninstall-{env}' invoke 'helm
   uninstall', so a missing or too-old Helm would surface as a raw
   process-spawn / unknown-flag error during teardown instead of the
   actionable validator message. Add a 'DependsOn(check-helm-prereqs-
   {env})' on both, and add a regression test that asserts the
   dependency edge exists.

2. Fix the misleading comment above HelmVersionRegex. The regex is
   intentionally unanchored so we tolerate banner/shim lines that
   some shells, oh-my-zsh plugins, or asdf-style shims can prepend
   to the version output. Update the comment to describe that
   intent instead of claiming a start anchor that isn't there.

3. Shorten the Helm prerequisite bullets in both Kubernetes README
   files. Keep the bullet to the requirement itself and move the
   'why we validate up front' narrative into a short paragraph
   below, matching the scannable style of the other hosting READMEs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mitchdenny and others added 2 commits May 27, 2026 09:48
The 11 DeployK8s* CLI E2E tests failed on commit d03916c because the
container install scripts default HELM_VERSION to v3.17.3 — below the
new HelmVersionValidator.MinimumHelmVersion (v4.2.0) that the
check-helm-prereqs-{env} pipeline step now enforces.

Centralize the version constants in a new
tests/Aspire.Cli.EndToEnd.Tests/Helpers/KubernetesE2EVersions.cs so the
default lives in one place (and points at the validator's documented
minimum), then bump HelmVersion default v3.17.3 -> v4.2.0 (used by every
DeployK8s* test and by the quarantined KubernetesPublishTests).

HELM_VERSION / KIND_VERSION / KUBECTL_VERSION env-var overrides are
preserved so CI can still bump to a newer point release without a
code change.

The AKS deployment workflow (deployment-tests.yml) still pins
azure/setup-helm to v4.1.4 and needs the same bump to v4.2.0 to avoid
breaking AKS scenarios under the new validator; that workflow file edit
will land in a separate push that has 'workflow' OAuth scope.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Match Aspire.Hosting.Kubernetes' new minimum supported Helm version
(HelmVersionValidator.MinimumHelmVersion). The check-helm-prereqs-{env}
pipeline step now fails fast on older Helm CLIs, so leaving the AKS
deployment workflow pinned to v4.1.4 would break every AKS deployment
scenario. Also refresh the surrounding rationale comment, which still
referred to the historical v3.18 server-side narrative.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mitchdenny
Copy link
Copy Markdown
Member Author

/deployment-test

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Deployment tests starting on PR #17491...

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

View workflow run

@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 00:42 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 00:42 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 00:42 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 00:42 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 00:42 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 00:42 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 00:42 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 00:42 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 00:42 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 00:42 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 00:42 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 00:42 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 00:42 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 00:42 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 00:42 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 00:42 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 02:08 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 02:08 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 02:08 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 02:08 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 02:08 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 02:08 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 02:08 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 02:08 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 02:08 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 02:08 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 02:08 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 02:08 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 02:08 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 02:08 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 02:08 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 02:08 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 27, 2026 02:08 Inactive
@github-actions
Copy link
Copy Markdown
Contributor

Deployment E2E Tests passed — 40 passed, 0 failed, 0 cancelled

View test results and recordings

View workflow run

Test Result Recording
Deployment.EndToEnd-TypeScriptJavaScriptHostingDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-TypeScriptVnetSqlServerInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaCustomRegistryDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureKeyVaultDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureStorageDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureServiceBusDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetSqlServerInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-TypeScriptExpressDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetSqlServerConnectivityDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaCompactNamingDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-KubernetesGatewayTlsDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-FrontDoorDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-KubernetesHelmChartDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureLogAnalyticsDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-NspStorageKeyVaultDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetKeyVaultInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetKeyVaultConnectivityDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksStarterDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksAzureKubernetesEnvironmentGatewayDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-TypeScriptAzureContainerAppJobDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaDeploymentErrorOutputTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksStarterWithRedisHelmDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksWithAzureResourcesDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureAppConfigDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetStorageBlobInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksAzureKubernetesEnvironmentCertManagerDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksMultipleNodePoolsDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksBlazorRedisDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AuthenticationTests ✅ Passed
Deployment.EndToEnd-AksAzureKubernetesEnvironmentCertManagerTypeScriptDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaStarterDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksVnetInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetStorageBlobConnectivityDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureEventHubsDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaExistingRegistryDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureContainerRegistryDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AppServiceReactDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaManagedRedisDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksWithHelmChartDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksVnetWithAzureResourcesDeploymentTests ✅ Passed ▶️ View Recording

@davidfowl
Copy link
Copy Markdown
Contributor

PR Testing Report

PR Information

CLI Version Verification

  • Expected Commit: b5c7535
  • Installed Version: 13.4.0-pr.17491.gb5c75355
  • Status: ✅ Verified; installed CLI version contains PR head short SHA b5c75355.

Changes Analyzed

Files Changed

  • .github/workflows/deployment-tests.yml
  • src/Aspire.Hosting.Azure.Kubernetes/README.md
  • src/Aspire.Hosting.Kubernetes/Deployment/HelmDeploymentEngine.cs
  • src/Aspire.Hosting.Kubernetes/Deployment/HelmVersionValidator.cs
  • src/Aspire.Hosting.Kubernetes/KubernetesHelmChartExtensions.cs
  • src/Aspire.Hosting.Kubernetes/README.md
  • tests/Aspire.Cli.EndToEnd.Tests/Helpers/KubernetesDeployTestHelpers.cs
  • tests/Aspire.Cli.EndToEnd.Tests/Helpers/KubernetesE2EVersions.cs
  • tests/Aspire.Cli.EndToEnd.Tests/KubernetesPublishTests.cs
  • tests/Aspire.Hosting.Kubernetes.Tests/FakeHelmRunner.cs
  • tests/Aspire.Hosting.Kubernetes.Tests/HelmVersionValidatorTests.cs
  • tests/Aspire.Hosting.Kubernetes.Tests/KubernetesDeployTests.cs

Change Categories

  • CLI changes detected
  • Hosting integration changes detected — Kubernetes deploy now validates Helm CLI version before deployment.
  • Dashboard changes detected
  • Template changes detected
  • Client/Component changes detected
  • Test/docs changes detected — Kubernetes deploy tests, workflow tool versions, and README prerequisites.

Test Environment

  • OS: Ubuntu 24.04 x64 on DigitalOcean
  • .NET SDK: 10.0.300
  • Helm: v4.2.0+g0646808
  • Kubernetes: local k3s v1.35.5+k3s1
  • App creation: fresh aspire-empty single-file C# AppHost projects under /tmp/aspire-pr17491-test
  • PR package source: /tmp/aspire-pr17491-cli/hives/pr-17491/packages

Test Scenarios Executed

Scenario 1: PR CLI/version verification

Objective: Install the PR dogfood CLI and verify it matches the latest PR head commit.
Coverage Type: Happy path
Status: ✅ Passed

Steps:

  1. Downloaded the Linux x64 dogfood CLI for PR Validate Helm CLI version (>= 4.2.0) before Kubernetes deploy #17491 using the PR installer and copied it to the droplet.
  2. Ran the installed binary directly: /tmp/aspire-pr17491-cli/dogfood/pr-17491/bin/aspire --version.
  3. Compared the reported version with PR head commit b5c75355a8c4f947818496f35ad47c0336f5136f.

Evidence:

  • Log: aspire-pr17491-test/logs/version.txt

Observations:

  • Installed version was 13.4.0-pr.17491.gb5c75355, matching the PR head short SHA.

Scenario 2: Happy-path Kubernetes deploy with Helm 4.2.0

Objective: Validate that Kubernetes deployment proceeds when Helm meets the new minimum version requirement.
Coverage Type: Happy path
Status: ✅ Passed

Steps:

  1. Created a fresh aspire-empty C# AppHost project.
  2. Added Aspire.Hosting.Kubernetes from the PR hive.
  3. Configured builder.AddKubernetesEnvironment("env") with Helm release pr17491-happy2.
  4. Added an nginx:1.27-alpine container resource with HTTP target port 80.
  5. Ran aspire deploy --apphost <apphost.cs> --non-interactive --clear-cache --include-exception-details against the droplet's local k3s cluster.
  6. Verified Helm release status and Kubernetes resources, then uninstalled the release.

Evidence:

  • Log: aspire-pr17491-test/logs/happy2-deploy.log
  • Log: aspire-pr17491-test/logs/happy2-evidence.log
  • Cleanup log: aspire-pr17491-test/logs/happy2-cleanup.log

Observations:

  • helm list showed release pr17491-happy2 as deployed.
  • helm status reported STATUS: deployed.
  • kubectl get all showed env-dashboard-deployment and nginx-deployment both 1/1 and running.
  • kubectl rollout status deployment/nginx-deployment completed successfully.

Scenario 3: Too-old Helm rejection

Objective: Verify Aspire fails early with an actionable error when helm version --short reports Helm below 4.2.0.
Coverage Type: Unhappy path
Status: ✅ Passed

Steps:

  1. Created a fresh AppHost with the same Kubernetes environment and nginx resource.
  2. Prepended a fake helm executable to PATH that returns v4.1.0+gfake for helm version --short.
  3. Ran aspire deploy --non-interactive.

Expected Unhappy-Path Outcome: Non-zero exit before Helm install/upgrade, with a message that includes the detected version, required version, and Helm install docs.

Evidence:

  • Log: aspire-pr17491-test/logs/old-helm.log

Observations:

  • Command exited non-zero (6).
  • Output included: Helm 4.1.0 was detected, but Aspire requires Helm 4.2.0 or later to deploy Kubernetes resources. Upgrade Helm from https://helm.sh/docs/intro/install/.
  • Failure occurred in check-helm-prereqs-env before any deploy step used the fake Helm for installation.

Scenario 4: Unparseable Helm output rejection

Objective: Verify Aspire fails early and clearly when Helm version output cannot be parsed.
Coverage Type: Unhappy path
Status: ✅ Passed

Steps:

  1. Created a fresh AppHost with the same Kubernetes environment and nginx resource.
  2. Prepended a fake helm executable to PATH that returns garbage banner for helm version --short.
  3. Ran aspire deploy --non-interactive.

Expected Unhappy-Path Outcome: Non-zero exit before deploy with a parse error and Helm install guidance.

Evidence:

  • Log: aspire-pr17491-test/logs/garbage-helm.log

Observations:

  • Command exited non-zero (6).
  • Output included: Could not parse Helm version from 'helm version --short' output: 'garbage banner'. Aspire requires Helm 4.2.0 or later. See https://helm.sh/docs/intro/install/.

Scenario 5: Helm version command failure

Objective: Verify Aspire reports an actionable error when helm version --short itself exits non-zero.
Coverage Type: Unhappy path
Status: ✅ Passed

Steps:

  1. Created a fresh AppHost with the same Kubernetes environment and nginx resource.
  2. Prepended a fake helm executable to PATH that writes simulated helm version failure to stderr and exits 1 for helm version --short.
  3. Ran aspire deploy --non-interactive.

Expected Unhappy-Path Outcome: Non-zero exit before deploy with command failure detail and Helm install guidance.

Evidence:

  • Log: aspire-pr17491-test/logs/fail-helm.log

Observations:

  • Command exited non-zero (6).
  • Output included: 'helm version --short' failed (simulated helm version failure). Aspire requires Helm 4.2.0 or later. See https://helm.sh/docs/intro/install/.

Summary

Scenario Status Notes
PR CLI/version verification ✅ Passed Version 13.4.0-pr.17491.gb5c75355 matched PR head short SHA.
Happy-path Kubernetes deploy ✅ Passed Helm 4.2.0 deploy completed; nginx and dashboard deployments reached 1/1.
Too-old Helm rejection ✅ Passed Helm 4.1.0 failed early with required-version/install-docs message.
Unparseable Helm output rejection ✅ Passed Invalid version text failed early with parse/install-docs message.
Helm version command failure ✅ Passed Non-zero version probe failed early with stderr detail/install-docs message.

Overall Result

✅ PR VERIFIED

The PR CLI build for #17491 validated the new Helm prerequisite behavior on a fresh DigitalOcean droplet. Kubernetes deploy succeeds with Helm 4.2.0 and fails early with clear actionable errors for too-old, unparseable, and failing Helm version probes.

Artifacts

  • Logs and raw command output retained in the tester session artifacts.

Comment thread src/Aspire.Hosting.Kubernetes/Deployment/HelmDeploymentEngine.cs Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

@github-actions
Copy link
Copy Markdown
Contributor

CLI E2E Tests unknown — 107 passed, 0 failed, 2 unknown (commit 647c241)

View all recordings
Status Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View recording
AddPackageWhileAppHostRunningDetached ▶️ View recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View recording
AgentInitCommand_DefaultSelection_InstallsDefaultSkills ▶️ View recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View recording
AgentMcpListStructuredLogsReturnsLogsFromStarterApp ▶️ View recording
AgentMcpListStructuredLogsReturnsLogsFromStarterApp_DevLocalhost ▶️ View recording
AgentMcpListStructuredLogsReturnsLogsFromStarterApp_Isolated ▶️ View recording
AllPublishMethodsBuildDockerImages ▶️ View recording
AspireAddAndStartWorkAgainstLegacyAppHostTs ▶️ View recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View recording
AspireInitSingleFileAppHostRunsViaDotnetRunAppHost ▶️ View recording
AspireInitWithExistingAppHostDirRecreatesMissingNuGetConfigAndPreservesFiles ▶️ View recording
AspireInitWithSolutionFileGeneratesAppHostThatBuildsAgainstChannelHive ▶️ View recording
AspireStartUpdatesStaleTypeScriptAppHostPath ▶️ View recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View recording
AspireUpdateRemovesOrphanAppHostPackageVersionWhenSdkAlreadyCurrent ▶️ View recording
Banner_DisplayedOnFirstRun ▶️ View recording
Banner_DisplayedWithExplicitFlag ▶️ View recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View recording
CertificatesClean_RemovesCertificates ▶️ View recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View recording
CreateAndRunAspireStarterProject ▶️ View recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View recording
CreateAndRunEmptyAppHostProject ▶️ View recording
CreateAndRunJavaEmptyAppHostProject ▶️ View recording
CreateAndRunJsReactProject ▶️ View recording
CreateAndRunPythonReactProject ▶️ View recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View recording
CreateAndRunTypeScriptStarterProject ▶️ View recording
CreateJavaAppHostWithViteApp ▶️ View recording
CreateTypeScriptAppHostWithViteApp_AllowsGuestAppPackageManagerToDiffer ▶️ View recording
CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchain ▶️ View recording
DashboardRunWithAgentMcpListTracesReturnsNoTraces ▶️ View recording
DashboardRunWithAgentMcpListTracesReturnsNoTraces_DevLocalhost ▶️ View recording
DashboardRunWithOtelTracesReturnsNoTraces ▶️ View recording
DashboardRunWithOtelTracesReturnsNoTraces_DevLocalhost ▶️ View recording
DeployK8sBasicApiService ▶️ View recording
DeployK8sWithExternalHelmChart ▶️ View recording
DeployK8sWithGarnet ▶️ View recording
DeployK8sWithMongoDB ▶️ View recording
DeployK8sWithMySql ▶️ View recording
DeployK8sWithPostgres ▶️ View recording
DeployK8sWithRabbitMQ ▶️ View recording
DeployK8sWithRedis ▶️ View recording
DeployK8sWithSqlServer ▶️ View recording
DeployK8sWithValkey ▶️ View recording
DeployTypeScriptAppToKubernetes ▶️ View recording
DescribeCommandResolvesReplicaNames ▶️ View recording
DescribeCommandShowsRunningResources ▶️ View recording
DetachFormatJsonProducesValidJson ▶️ View recording
DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance ▶️ View recording
DoListStepsShowsPipelineSteps ▶️ View recording
DocsCommand_RendersInteractiveMarkdownFromLocalSource ▶️ View recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View recording
DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchain ▶️ View recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View recording
GatewayWithoutExternalEndpoint_FailsPublishWithGuidance ▶️ View recording
GeneratedAspireDevScript_StartsWatchMode_WithConfiguredToolchain ▶️ View recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View recording
GlobalMigration_PreservesAllValueTypes ▶️ View recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View recording
IngressWithoutExternalEndpoint_FailsPublishWithGuidance ▶️ View recording
InitTypeScriptAppHost_AugmentsExistingViteRepoInWorkspaceSubdirectory ▶️ View recording
InteractiveCSharpInitCreatesExpectedFiles ▶️ View recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View recording
JavaScriptHostingApisRunFromTypeScriptAppHost ▶️ View recording
LatestCliCanStartStableChannelAppHost ▶️ View recording
LatestCliCanStartStableChannelTypeScriptAppHost ▶️ View recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View recording
LogsCommandShowsResourceLogs ▶️ View recording
OtelLogsReturnsStructuredLogsFromStarterApp ▶️ View recording
OtelLogsReturnsStructuredLogsFromStarterAppIsolated ▶️ View recording
PsCommandListsRunningAppHost ▶️ View recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View recording
PublishJavaScriptPatternsGeneratesExpectedDockerComposeArtifacts ▶️ View recording
PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View recording
PublishWithoutOutputPathUsesAppHostDirectoryDefault ▶️ View recording
ResourceCommand_FailedExecution_DisplaysAppHostLogPathAndLogContainsEntries ▶️ View recording
ResourceCommand_SetAndDeleteParameterUpdatesDescribeOutput ▶️ View recording
RestoreGeneratesSdkFiles ▶️ View recording
RestoreGeneratesSdkFiles_WithConfiguredToolchain ▶️ View recording
RestoreRefreshesGeneratedSdkAfterAddingIntegration ▶️ View recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View recording
RunReportsSyntaxErrorsForDotNetAppHost ▶️ View recording
RunReportsSyntaxErrorsForTypeScriptAppHost ▶️ View recording
SecretCrudOnDotNetAppHost ▶️ View recording
SecretCrudOnTypeScriptAppHost ▶️ View recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View recording
StartReportsSyntaxErrorsForDotNetAppHost ▶️ View recording
StartReportsSyntaxErrorsForTypeScriptAppHost ▶️ View recording
StopAllAppHostsFromAppHostDirectory ▶️ View recording
StopJavaPolyglotAppHostUsingApphostDirectory ▶️ View recording
StopNonInteractiveSingleAppHost ▶️ View recording
StopTypeScriptPolyglotAppHostUsingApphostDirectory ▶️ View recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View recording
UpdateProjectChannelToStable_CSharpEmptyAppHost_PreservesAspireConfigChannel ▶️ View recording
UpdateProjectChannelToStable_CSharpSingleFileInit_PreservesAspireConfigChannel ▶️ View recording
UpdateProjectChannelToStable_TypeScriptSingleFileInit_PreservesAspireConfigChannel ▶️ View recording
UpdateProjectChannelToStable_TypeScript_PreviewsStablePackagesAndPreservesChannel ▶️ View recording

📹 Recordings uploaded automatically from CI run #26507816679

@mitchdenny
Copy link
Copy Markdown
Member Author

/backport to release/13.4

@github-actions
Copy link
Copy Markdown
Contributor

Started backporting to release/13.4 (link to workflow run)

@aspire-repo-bot
Copy link
Copy Markdown
Contributor

Pull request created: #1090

Generated by PR Documentation Check

@aspire-repo-bot
Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#1090 targeting release/13.4.

Updated two existing pages to document the Helm v4.2.0+ minimum prerequisite introduced by this PR:

  • src/frontend/src/content/docs/deployment/kubernetes.mdx — new Prerequisites section listing Helm v4.2.0+ and kubectl as required tools before deploying.
  • src/frontend/src/content/docs/integrations/compute/kubernetes.mdx — added a callout note in the Installation section explaining the Helm version requirement and why it's enforced (clear error vs. cryptic flag failures).

Note

This draft PR needs human review before merging.

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.

Validate Helm is installed and assert compatible version for Kubernetes deploy

4 participants