-
Notifications
You must be signed in to change notification settings - Fork 982
Add AKS persistent volume support #19226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Mitch Denny (mitchdenny)
merged 5 commits into
main
from
mitchdenny-add-aks-persistent-volumes
Aug 12, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
254d583
Add AKS persistent volume support
mitchdenny 9ecd72b
Pin AKS volume test node pools
mitchdenny 100b530
Allow API writes to AKS managed disk
mitchdenny 4b0cc66
Await AKS deployment cleanup
mitchdenny a5da9c6
Dispose AKS deployment workspace
mitchdenny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/Aspire.Hosting.Azure.Kubernetes/AzureKubernetesPersistentVolumeExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Diagnostics.CodeAnalysis; | ||
| using Aspire.Hosting.ApplicationModel; | ||
| using Aspire.Hosting.Azure.Kubernetes; | ||
| using Aspire.Hosting.Kubernetes; | ||
|
|
||
| namespace Aspire.Hosting; | ||
|
|
||
| /// <summary> | ||
| /// Provides extension methods for adding Kubernetes persistent volumes to an | ||
| /// <see cref="AzureKubernetesEnvironmentResource"/>. | ||
| /// </summary> | ||
| [Experimental("ASPIRECOMPUTE002", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] | ||
| public static class AzureKubernetesPersistentVolumeExtensions | ||
| { | ||
| /// <summary> | ||
| /// Adds a Kubernetes PersistentVolumeClaim resource to the application model for the | ||
| /// specified AKS environment. | ||
| /// </summary> | ||
| /// <ats-summary>Adds a Kubernetes PersistentVolumeClaim resource to an AKS environment</ats-summary> | ||
| /// <param name="builder">The AKS environment resource builder.</param> | ||
| /// <param name="name">The name of the persistent volume resource.</param> | ||
| /// <returns>A builder for the new <see cref="KubernetesPersistentVolumeResource"/>.</returns> | ||
| /// <ats-returns>The resource builder.</ats-returns> | ||
| /// <remarks> | ||
| /// <para> | ||
| /// The persistent volume is associated with the AKS environment's underlying Kubernetes | ||
| /// environment and generates a <c>v1.PersistentVolumeClaim</c> in the Helm chart output. | ||
| /// </para> | ||
| /// <para> | ||
| /// When no storage class is configured, the generated claim omits | ||
| /// <c>spec.storageClassName</c> so the cluster's default storage class is used. A standard | ||
| /// AKS cluster dynamically provisions an Azure managed disk for such claims. Use | ||
| /// <see cref="KubernetesPersistentVolumeExtensions.WithStorageClass(IResourceBuilder{KubernetesPersistentVolumeResource}, string)"/> | ||
| /// to select a different storage class explicitly. | ||
| /// </para> | ||
| /// </remarks> | ||
| /// <ats-remarks /> | ||
| /// <example> | ||
| /// <code> | ||
| /// var aks = builder.AddAzureKubernetesEnvironment("aks"); | ||
| /// | ||
| /// var data = aks.AddPersistentVolume("data") | ||
| /// .WithCapacity("20Gi"); | ||
| /// | ||
| /// builder.AddProject<Projects.Api>("api") | ||
| /// .WithPersistentVolume(data, "/data"); | ||
| /// </code> | ||
| /// </example> | ||
| [AspireExport] | ||
| public static IResourceBuilder<KubernetesPersistentVolumeResource> AddPersistentVolume( | ||
| this IResourceBuilder<AzureKubernetesEnvironmentResource> builder, | ||
| [ResourceName] string name) | ||
| { | ||
| ArgumentNullException.ThrowIfNull(builder); | ||
| ArgumentException.ThrowIfNullOrEmpty(name); | ||
|
|
||
| var k8sEnvBuilder = builder.ApplicationBuilder.CreateResourceBuilder(builder.Resource.KubernetesEnvironment); | ||
| return k8sEnvBuilder.AddPersistentVolume(name); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.