Skip to content
DocsTry Aspire
DocsTry

KubernetesPersistentVolumeExtensions

Classstaticnet10.0
📦 Aspire.Hosting.Kubernetes v13.5.1-preview.1.26420.4
Provides extension methods for configuring Kubernetes KubernetesPersistentVolumeResource resources and binding workloads to them.
namespace Aspire.Hosting;
public static class KubernetesPersistentVolumeExtensions
{
// ...
}
AddPersistentVolume(IResourceBuilder<KubernetesEnvironmentResource>, string)extensionats export
IResourceBuilder<KubernetesPersistentVolumeResource>
Adds a Kubernetes PersistentVolumeClaim resource to the application model as a child of the specified Kubernetes environment. The resource generates a v1.PersistentVolumeClaim manifest in the Helm chart output at publish time.
WithAccessMode(IResourceBuilder<KubernetesPersistentVolumeResource>, PersistentVolumeAccessMode)extensionats export
IResourceBuilder<KubernetesPersistentVolumeResource>
WithCapacity(IResourceBuilder<KubernetesPersistentVolumeResource>, string)extensionats export
IResourceBuilder<KubernetesPersistentVolumeResource>
Sets the requested storage capacity on the PVC's spec.resources.requests.storage field.
WithCapacity(IResourceBuilder<KubernetesPersistentVolumeResource>, IResourceBuilder<ParameterResource>)extensionats export
IResourceBuilder<KubernetesPersistentVolumeResource>
Sets the requested storage capacity using a parameter resolved at deploy time.
WithPersistentVolume(IResourceBuilder<T>, IResourceBuilder<KubernetesPersistentVolumeResource>)extensionats export
IResourceBuilder<T>
Binds a workload to a Kubernetes KubernetesPersistentVolumeResource using name matching. The workload must already declare a volume with a matching source name (typically via WithVolume("name", "/path") or an integration helper such as Postgres' WithDataVolume()). The publisher rewrites that volume's pod-spec entry to reference the generated PVC and promotes the workload to a StatefulSet.
WithPersistentVolume(IResourceBuilder<T>, IResourceBuilder<KubernetesPersistentVolumeResource>, string, bool)extensionats export
IResourceBuilder<T>
Binds a workload to a Kubernetes KubernetesPersistentVolumeResource and mounts it at the specified path inside the workload's container. Unlike the name-match overload this one creates the underlying mount itself, so it works for workloads that don't already declare a named volume — including ApplicationModel.ProjectResource.
WithStorageClass(IResourceBuilder<KubernetesPersistentVolumeResource>, string)extensionats export
IResourceBuilder<KubernetesPersistentVolumeResource>
Sets the Kubernetes storage class name on the PVC's spec.storageClassName. When unset, the cluster's default storage class is used.
WithStorageClass(IResourceBuilder<KubernetesPersistentVolumeResource>, IResourceBuilder<ParameterResource>)extensionats export
IResourceBuilder<KubernetesPersistentVolumeResource>
Sets the Kubernetes storage class name using a parameter resolved at deploy time.
WithVolumeAnnotation(IResourceBuilder<KubernetesPersistentVolumeResource>, string, string)extensionats export
IResourceBuilder<KubernetesPersistentVolumeResource>
Adds a Kubernetes metadata annotation to the generated PVC. These flush to metadata.annotations on the rendered Kubernetes resource — not Aspire ApplicationModel.IResourceAnnotation instances. Common uses: CSI driver hints, dynamic provisioner parameters, external-secrets selectors, or backup tooling tags.
WithVolumeAnnotation(IResourceBuilder<KubernetesPersistentVolumeResource>, string, IResourceBuilder<ParameterResource>)extensionats export
IResourceBuilder<KubernetesPersistentVolumeResource>
Adds a Kubernetes metadata annotation with a parameter value resolved at deploy time.
View all methods