# WithKindNetwork

- Module: [CommunityToolkit.Aspire.Hosting.Kind](/reference/api/go/communitytoolkit.aspire.hosting.kind.md)
- Version: `13.5.1-beta.895`
- Kind: `method`
- Defined on: `ContainerResource`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/tree/2c26a4c9649531d17fce3cbc4c5dea00d61d279c)

Connects a container resource to the Kind container network, enabling it to communicate with the Kind cluster's API server and nodes.

## Remarks

Use this method when a container needs direct network connectivity to the Kind control plane.
Kind creates a separate container network ("kind") for its nodes. Aspire manages
its own container network for containers it creates. Containers on different
networks cannot communicate by default.
Aspire does not provide a built-in way to add containers to additional container networks,
and `WithContainerRuntimeArgs("--network", "kind")` is overridden internally.
See for the upstream feature request.
This method works around the limitation by subscribing to the container's stopped event.
When the container stops (typically because it can't reach the Kind cluster), the hook
connects the container to the "kind" network via the configured container runtime and
restarts it.
If the container does not already have an explicit name (via `WithContainerName`),
this method assigns one using the pattern `{resource.Name}-{random}` to ensure
the container can be identified by the handler.

## Definition

```go
func (ContainerResource) WithKindNetwork() ContainerResource
```

## Returns

`ContainerResource` -- A reference to the `IResourceBuilder`.

Returns a handle; failures surface later via `Err()`.

## Applies to

- `ContainerResource`
- [`KubernetesAspireDashboardResource`](/reference/api/go/communitytoolkit.aspire.hosting.kind/kubernetesaspiredashboardresource.md)
