Skip to content

Added .WithDynamicProvisioning method and default for specifying PV and PVC publishing behavior#16503

Open
cdbrown2018 wants to merge 5 commits into
microsoft:mainfrom
cdbrown2018:cdbrown2018/k8s-dynamic-provisioning
Open

Added .WithDynamicProvisioning method and default for specifying PV and PVC publishing behavior#16503
cdbrown2018 wants to merge 5 commits into
microsoft:mainfrom
cdbrown2018:cdbrown2018/k8s-dynamic-provisioning

Conversation

@cdbrown2018

Copy link
Copy Markdown

Description

Added the ability to publish helm templates for a PVC without requiring an accompanying PV.

Usage:

Control default policy:

builder.AddKubernetesEnvironment("k8s")
    .WithProperties(properties => {
        properties.DefaultShouldDynamicallyProvision = true; // Tells publisher to only create a PVC by default (no PV).
    });

Override on a per-resource basis:

builder.AddContainer("my-container", "registry")
.WithDynamicProvisioning(true); // Overrides default behavior for PVC/PV creation.

To maintain backwards-compatibility, dynamic provisioning is off by default.

Fixes #9429

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
  • Does the change require an update in our Aspire docs?

@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 -- 16503

Or

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

@cdbrown2018

Copy link
Copy Markdown
Author

@cdbrown2018 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

@IEvangelist

IEvangelist commented May 20, 2026

Copy link
Copy Markdown
Member

PR testing report

PR: #16503 - Added .WithDynamicProvisioning method and default for specifying PV and PVC publishing behavior
Head commit: de4ab5bfbf89c6459c6116b8895b57bc30d2be6f
Result: Blocked - PR dogfood CLI artifact was unavailable

CLI version verification

The PR dogfood installer was invoked, but the expected Windows CLI artifact could not be downloaded from the workflow run referenced by the dogfood instructions. Because the PR CLI could not be installed, the CLI version could not be verified against the PR head commit and no runtime/publish scenarios were executed.

text Starting download and installation for PR #16503 Using workflow run https://github.com/microsoft/aspire/actions/runs/25032885083 Downloading CLI from GitHub - cli-native-archives-win-x64 ... INSTALL_FAILED: Error: Failed to download artifact 'cli-native-archives-win-x64' from run: 25032885083 . If the workflow is still running then the artifact named 'cli-native-archives-win-x64' may not be available yet. Check at https://github.com/microsoft/aspire/actions/runs/25032885083#artifacts

Changes analyzed

This PR changes Kubernetes PV/PVC dynamic provisioning behavior:

  • src/Aspire.Hosting.Kubernetes/Annotations/KubernetesProvisioningPolicyAnnotation.cs
  • src/Aspire.Hosting.Kubernetes/Extensions/ResourceExtensions.cs
  • src/Aspire.Hosting.Kubernetes/KubernetesEnvironmentResource.cs

Planned scenarios

These scenarios were selected based on the changed files, but were not executed because CLI installation failed first:

  1. Verify the installed PR dogfood Aspire CLI reports the PR head commit.
  2. Create a temp Aspire app with a Kubernetes environment and a resource that creates a PVC, publish Kubernetes artifacts with the default behavior, and verify both PVC and PV YAML are generated.
  3. Enable dynamic provisioning on a resource and publish again, verifying the PVC remains and the PV YAML is omitted.
  4. Enable dynamic provisioning at the Kubernetes environment default and verify resource-level overrides still behave as expected.

Overall: Not verified. Please rerun after the PR dogfood workflow publishes the expected cli-native-archives-win-x64 artifact.

@cdbrown2018

Copy link
Copy Markdown
Author

I believe this PR is going to be closed when #16929 lands. Would it be best to update this PR with latest and fix the Dogfooding issues, or should we let this sit until #16929 is settled?

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.

Ability to create PVC without defining a PV

3 participants