Watch Aspire live streamsDocsTry Aspire

KindClusterResourceBuilderExtensions Methods

ClassMethods8 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 on graceful shutdown or other process-exit signals on a best-effort basis. 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.
WithNodeImage(IResourceBuilder<T>, string)Section titled WithNodeImage(IResourceBuilder<T>, string)extensionIResourceBuilder<T>
Sets the Kind node image for every node in the cluster.
public static class KindClusterResourceBuilderExtensions
{
public static IResourceBuilder<T> WithNodeImage<T>(
this IResourceBuilder<T> builder,
string image)
{
// ...
}
}
builderIResourceBuilder<T>The resource builder.
imagestring The fully qualified Kind node image, such as kindest/node:v1.33.1. This overrides the image that would otherwise be derived from KindClusterResourceBuilderExtensions.WithKubernetesVersion.
IResourceBuilder<T>A reference to the ApplicationModel.IResourceBuilder`1.
WithNodeMount(IResourceBuilder<T>, string, string, bool)Section titled WithNodeMount(IResourceBuilder<T>, string, string, bool)extensionIResourceBuilder<T>
Adds an extra host mount to every Kind node container.
public static class KindClusterResourceBuilderExtensions
{
public static IResourceBuilder<T> WithNodeMount<T>(
this IResourceBuilder<T> builder,
string hostPath,
string containerPath,
bool readOnly = false)
{
// ...
}
}
builderIResourceBuilder<T>The resource builder.
hostPathstring The path on the host. Relative paths are resolved against the AppHost directory before being written to the Kind config.
containerPathstringThe absolute path inside the Kind node container.
readOnlybooloptionaltrue to mount the path read-only.
IResourceBuilder<T>A reference to the ApplicationModel.IResourceBuilder`1.
This configures Kind node-container mounts, which are useful for surfacing host-side assets such as local manifest directories, certificates, or other development-time inputs to workloads that later mount paths from the node filesystem.
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.