KindContainerExtensions Methods
WithKindNetwork(IResourceBuilder<ContainerResource>)Section titled WithKindNetwork(IResourceBuilder<ContainerResource>)extensionIResourceBuilder<ContainerResource>public static class KindContainerExtensions{ public static IResourceBuilder<ContainerResource> WithKindNetwork( this IResourceBuilder<ContainerResource> builder) { // ... }}Parameters
builderIResourceBuilder<ContainerResource>The container resource builder.Returns
IResourceBuilder<ContainerResource>A reference to the ApplicationModel.IResourceBuilder`1.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 https://github.com/microsoft/aspire/issues/14081 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.
WithReference(IResourceBuilder<ContainerResource>, IResourceBuilder<KindClusterResource>)Section titled WithReference(IResourceBuilder<ContainerResource>, IResourceBuilder<KindClusterResource>)extensionIResourceBuilder<ContainerResource>public static class KindContainerExtensions{ public static IResourceBuilder<ContainerResource> WithReference( this IResourceBuilder<ContainerResource> builder, IResourceBuilder<KindClusterResource> kind) { // ... }}Parameters
builderIResourceBuilder<ContainerResource>The container resource builder.kindIResourceBuilder<KindClusterResource>The Kind cluster resource builder.Returns
IResourceBuilder<ContainerResource>A reference to the ApplicationModel.IResourceBuilder`1.Remarks
This overload is the primary integration path for containers. It: /etc/kubeconfig/configKUBECONFIG to the in-container mount pathK8S_CLUSTER_NAME to the Kind cluster name
The container-compatible kubeconfig uses the Kind control-plane container name ( {clusterName}-control-plane) instead of 127.0.0.1, enabling container-to-container communication over the Kind container network.