Skip to content
DocsTry Aspire
DocsTry

KindClusterResourceBuilderExtensions Methods

ClassMethods6 members
Extension methods for adding Kind cluster resources to the distributed application builder.
AddKindCluster(IDistributedApplicationBuilder, string)Section titled AddKindCluster(IDistributedApplicationBuilder, string)extensionIResourceBuilder<KindClusterResource>
Adds a Kind cluster resource to the application model.
public static class KindClusterResourceBuilderExtensions
{
public static IResourceBuilder<KindClusterResource> AddKindCluster(
this IDistributedApplicationBuilder builder,
string name)
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder.
namestringThe name of the Kind cluster.
IResourceBuilder<KindClusterResource>A reference to the ApplicationModel.IResourceBuilder`1.
WithClusterLifetime(IResourceBuilder<T>, ClusterLifetime)Section titled WithClusterLifetime(IResourceBuilder<T>, ClusterLifetime)extensionIResourceBuilder<T>
Sets the cluster lifetime. When ClusterLifetime.Session (the default), the cluster is deleted when the AppHost shuts down. When ClusterLifetime.Persistent, the cluster survives AppHost restarts and is reused on next startup.
public static class KindClusterResourceBuilderExtensions
{
public static IResourceBuilder<T> WithClusterLifetime<T>(
this IResourceBuilder<T> builder,
ClusterLifetime lifetime)
{
// ...
}
}
builderIResourceBuilder<T>The resource builder.
lifetimeClusterLifetimeThe desired cluster lifetime.
IResourceBuilder<T>A reference to the ApplicationModel.IResourceBuilder`1.
WithKindConfig(IResourceBuilder<KindClusterResource>, Action<KindConfigModel>)Section titled WithKindConfig(IResourceBuilder<KindClusterResource>, Action<KindConfigModel>)extensionIResourceBuilder<KindClusterResource>
Customizes the Kind cluster configuration. The callback receives the KindConfigModel after default nodes have been populated, allowing arbitrary modifications before serialization to YAML.
public static class KindClusterResourceBuilderExtensions
{
public static IResourceBuilder<KindClusterResource> WithKindConfig(
this IResourceBuilder<KindClusterResource> builder,
Action<KindConfigModel> configure)
{
// ...
}
}
builderIResourceBuilder<KindClusterResource>The resource builder.
configureAction<KindConfigModel>A callback to customize the Kind configuration model.
IResourceBuilder<KindClusterResource>A reference to the ApplicationModel.IResourceBuilder`1.
Multiple calls to this method compose: each callback is applied in order during config generation.
WithKubernetesVersion(IResourceBuilder<T>, string)Section titled WithKubernetesVersion(IResourceBuilder<T>, string)extensionIResourceBuilder<T>
Sets the Kubernetes version for the Kind cluster.
public static class KindClusterResourceBuilderExtensions
{
public static IResourceBuilder<T> WithKubernetesVersion<T>(
this IResourceBuilder<T> builder,
string version)
{
// ...
}
}
builderIResourceBuilder<T>The resource builder.
versionstringThe Kubernetes version (e.g., "v1.32.2").
IResourceBuilder<T>A reference to the ApplicationModel.IResourceBuilder`1.
WithReference(IResourceBuilder<T>, IResourceBuilder<KindClusterResource>)Section titled WithReference(IResourceBuilder<T>, IResourceBuilder<KindClusterResource>)extensionIResourceBuilder<T>
Configures a non-container resource to reference the Kind cluster by injecting kubeconfig environment variables.
public static class KindClusterResourceBuilderExtensions
{
public static IResourceBuilder<T> WithReference<T>(
this IResourceBuilder<T> builder,
IResourceBuilder<KindClusterResource> kind)
{
// ...
}
}
builderIResourceBuilder<T>The resource builder.
kindIResourceBuilder<KindClusterResource>The Kind cluster resource builder.
IResourceBuilder<T>A reference to the ApplicationModel.IResourceBuilder`1.

This overload sets KUBECONFIG to the host kubeconfig path, which is appropriate for resources that execute on the host (e.g., executables, projects).

For container resources, use the KindContainerExtensions.WithReference overload instead, which handles container-specific requirements like bind-mounting and network connectivity.

WithWorkerNodes(IResourceBuilder<T>, int)Section titled WithWorkerNodes(IResourceBuilder<T>, int)extensionIResourceBuilder<T>
Sets the number of worker nodes for the Kind cluster.
public static class KindClusterResourceBuilderExtensions
{
public static IResourceBuilder<T> WithWorkerNodes<T>(
this IResourceBuilder<T> builder,
int count)
{
// ...
}
}
builderIResourceBuilder<T>The resource builder.
countintThe number of worker nodes. Must be zero or greater.
IResourceBuilder<T>A reference to the ApplicationModel.IResourceBuilder`1.