# KindClusterResourceBuilderExtensions Methods

- Package: [CommunityToolkit.Aspire.Hosting.Kind](/reference/api/csharp/communitytoolkit.aspire.hosting.kind.md)
- Type: [KindClusterResourceBuilderExtensions](/reference/api/csharp/communitytoolkit.aspire.hosting.kind/kindclusterresourcebuilderextensions.md)
- Kind: `Methods`
- Members: `8`

Extension methods for adding Kind cluster resources to the distributed application builder.

<a id="addkindcluster"></a>
<a id="addkindcluster-idistributedapplicationbuilder-string"></a>

## AddKindCluster(IDistributedApplicationBuilder, string)

- Name: `AddKindCluster(IDistributedApplicationBuilder, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<KindClusterResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/2c26a4c9649531d17fce3cbc4c5dea00d61d279c/src/CommunityToolkit.Aspire.Hosting.Kind/KindClusterResourceBuilderExtensions.cs#L32-L117)

Adds a Kind cluster resource to the application model.

```csharp
public static class KindClusterResourceBuilderExtensions
{
    public static IResourceBuilder<KindClusterResource> AddKindCluster(
        this IDistributedApplicationBuilder builder,
        string name)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder`.
- `name` (`string`)
  The name of the Kind cluster.

## Returns

`IResourceBuilder<KindClusterResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withclusterlifetime"></a>
<a id="withclusterlifetime-iresourcebuilder-t-clusterlifetime"></a>

## WithClusterLifetime(IResourceBuilder<T>, ClusterLifetime)

- Name: `WithClusterLifetime(IResourceBuilder<T>, ClusterLifetime)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/2c26a4c9649531d17fce3cbc4c5dea00d61d279c/src/CommunityToolkit.Aspire.Hosting.Kind/KindClusterResourceBuilderExtensions.cs#L247-L249)

Sets the cluster lifetime. When [ClusterLifetime.Session](/reference/api/csharp/communitytoolkit.aspire.hosting.kind/clusterlifetime/fields.md) (the default), the cluster is deleted on graceful shutdown or other process-exit signals on a best-effort basis. When [ClusterLifetime.Persistent](/reference/api/csharp/communitytoolkit.aspire.hosting.kind/clusterlifetime/fields.md), the cluster survives AppHost restarts and is reused on next startup.

```csharp
public static class KindClusterResourceBuilderExtensions
{
    public static IResourceBuilder<T> WithClusterLifetime<T>(
        this IResourceBuilder<T> builder,
        ClusterLifetime lifetime)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `lifetime` ([ClusterLifetime](/reference/api/csharp/communitytoolkit.aspire.hosting.kind/clusterlifetime.md))
  The desired cluster lifetime.

## Returns

`IResourceBuilder<T>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withkindconfig"></a>
<a id="withkindconfig-iresourcebuilder-kindclusterresource-action-kindconfigmodel"></a>

## WithKindConfig(IResourceBuilder<KindClusterResource>, Action<KindConfigModel>)

- Name: `WithKindConfig(IResourceBuilder<KindClusterResource>, Action<KindConfigModel>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<KindClusterResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/2c26a4c9649531d17fce3cbc4c5dea00d61d279c/src/CommunityToolkit.Aspire.Hosting.Kind/KindClusterResourceBuilderExtensions.cs#L267-L272)

Customizes the Kind cluster configuration. The callback receives the [KindConfigModel](/reference/api/csharp/communitytoolkit.aspire.hosting.kind/kindconfigmodel.md) after default nodes have been populated, allowing arbitrary modifications before serialization to YAML.

```csharp
public static class KindClusterResourceBuilderExtensions
{
    public static IResourceBuilder<KindClusterResource> WithKindConfig(
        this IResourceBuilder<KindClusterResource> builder,
        Action<KindConfigModel> configure)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<KindClusterResource>`)
  The resource builder.
- `configure` (`Action<KindConfigModel>`)
  A callback to customize the Kind configuration model.

## Returns

`IResourceBuilder<KindClusterResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## Remarks

Multiple calls to this method compose: each callback is applied in order during config generation.

## ATS metadata

### Ignored by ATS

- Reason: Action<KindConfigModel> is not ATS-compatible. Configure Kind config through ATS-supported APIs.

<a id="withkubernetesversion"></a>
<a id="withkubernetesversion-iresourcebuilder-t-string"></a>

## WithKubernetesVersion(IResourceBuilder<T>, string)

- Name: `WithKubernetesVersion(IResourceBuilder<T>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/2c26a4c9649531d17fce3cbc4c5dea00d61d279c/src/CommunityToolkit.Aspire.Hosting.Kind/KindClusterResourceBuilderExtensions.cs#L133-L139)

Sets the Kubernetes version for the Kind cluster.

```csharp
public static class KindClusterResourceBuilderExtensions
{
    public static IResourceBuilder<T> WithKubernetesVersion<T>(
        this IResourceBuilder<T> builder,
        string version)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `version` (`string`)
  The Kubernetes version (e.g., "v1.32.2").

## Returns

`IResourceBuilder<T>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withnodeimage"></a>
<a id="withnodeimage-iresourcebuilder-t-string"></a>

## WithNodeImage(IResourceBuilder<T>, string)

- Name: `WithNodeImage(IResourceBuilder<T>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/2c26a4c9649531d17fce3cbc4c5dea00d61d279c/src/CommunityToolkit.Aspire.Hosting.Kind/KindClusterResourceBuilderExtensions.cs#L158-L164)

Sets the Kind node image for every node in the cluster.

```csharp
public static class KindClusterResourceBuilderExtensions
{
    public static IResourceBuilder<T> WithNodeImage<T>(
        this IResourceBuilder<T> builder,
        string image)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `image` (`string`)
  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>, string)](/reference/api/csharp/communitytoolkit.aspire.hosting.kind/kindclusterresourcebuilderextensions/methods.md#withkubernetesversion-iresourcebuilder-t-string).

## Returns

`IResourceBuilder<T>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withnodemount"></a>
<a id="withnodemount-iresourcebuilder-t-string-string-bool"></a>

## WithNodeMount(IResourceBuilder<T>, string, string, bool)

- Name: `WithNodeMount(IResourceBuilder<T>, string, string, bool)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/2c26a4c9649531d17fce3cbc4c5dea00d61d279c/src/CommunityToolkit.Aspire.Hosting.Kind/KindClusterResourceBuilderExtensions.cs#L191-L210)

Adds an extra host mount to every Kind node container.

```csharp
public static class KindClusterResourceBuilderExtensions
{
    public static IResourceBuilder<T> WithNodeMount<T>(
        this IResourceBuilder<T> builder,
        string hostPath,
        string containerPath,
        bool readOnly = false)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `hostPath` (`string`)
  The path on the host. Relative paths are resolved against the AppHost directory before being written to the Kind config.
- `containerPath` (`string`)
  The absolute path inside the Kind node container.
- `readOnly` (`bool`) `optional`
  `true` to mount the path read-only.

## Returns

`IResourceBuilder<T>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## Remarks

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.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withreference"></a>
<a id="withreference-iresourcebuilder-t-iresourcebuilder-kindclusterresource"></a>

## WithReference(IResourceBuilder<T>, IResourceBuilder<KindClusterResource>)

- Name: `WithReference(IResourceBuilder<T>, IResourceBuilder<KindClusterResource>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/2c26a4c9649531d17fce3cbc4c5dea00d61d279c/src/CommunityToolkit.Aspire.Hosting.Kind/KindClusterResourceBuilderExtensions.cs#L365-L372)

Configures a non-container resource to reference the Kind cluster by injecting kubeconfig environment variables.

```csharp
public static class KindClusterResourceBuilderExtensions
{
    public static IResourceBuilder<T> WithReference<T>(
        this IResourceBuilder<T> builder,
        IResourceBuilder<KindClusterResource> kind)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `kind` (`IResourceBuilder<KindClusterResource>`)
  The Kind cluster resource builder.

## Returns

`IResourceBuilder<T>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## Remarks

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(IResourceBuilder<ContainerResource>, IResourceBuilder<KindClusterResource>)](/reference/api/csharp/communitytoolkit.aspire.hosting.kind/kindcontainerextensions/methods.md#withreference-iresourcebuilder-containerresource-iresourcebuilder-kindclusterresource) overload instead, which handles container-specific requirements like bind-mounting and network connectivity.

## ATS metadata

### ATS export

- Capability ID: `CommunityToolkit.Aspire.Hosting.Kind/withKindClusterReference`

<a id="withworkernodes"></a>
<a id="withworkernodes-iresourcebuilder-t-int"></a>

## WithWorkerNodes(IResourceBuilder<T>, int)

- Name: `WithWorkerNodes(IResourceBuilder<T>, int)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/2c26a4c9649531d17fce3cbc4c5dea00d61d279c/src/CommunityToolkit.Aspire.Hosting.Kind/KindClusterResourceBuilderExtensions.cs#L226-L229)

Sets the number of worker nodes for the Kind cluster.

```csharp
public static class KindClusterResourceBuilderExtensions
{
    public static IResourceBuilder<T> WithWorkerNodes<T>(
        this IResourceBuilder<T> builder,
        int count)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `count` (`int`)
  The number of worker nodes. Must be zero or greater.

## Returns

`IResourceBuilder<T>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
