Skip to content

Add Aspire.Hosting.Kind resource for local Kubernetes cluster provisioning #1232

Description

@tamirdresher

Summary

I'd like to propose adding an Aspire.Hosting.Kind integration resource that enables provisioning and managing local Kubernetes clusters using Kind (Kubernetes IN Docker) from within .NET Aspire application host code.

Motivation

Kind is the standard tool for running local Kubernetes clusters for development and CI/CD pipelines. Aspire already has excellent integrations for containers and cloud services, but there's currently no first-class way to spin up a local Kubernetes cluster as part of an Aspire app host. This gap means developers who want to test their apps on Kubernetes locally have to set up and manage Kind clusters manually, outside the Aspire lifecycle.

An Aspire.Hosting.Kind resource would:

  • Let developers declare a local k8s cluster as part of their Aspire app host
  • Automatically create/delete the Kind cluster with the app lifecycle
  • Support deploying Kubernetes manifests (Deployments, Services, ConfigMaps, etc.) onto the cluster
  • Integrate with Aspire's health checks, dashboard, and resource model
  • Simplify local k8s development for teams already using Aspire

Proposed API

var builder = DistributedApplication.CreateBuilder(args);

var cluster = builder.AddKindCluster("my-cluster")
    .WithKubernetesVersion("v1.30.0");

cluster.AddDeployment("api-deployment", "manifests/api-deployment.yaml");
cluster.AddService("api-service", "manifests/api-service.yaml");

builder.Build().Run();

Implementation

A working implementation already exists in the tamirdresher/aspire-kind repository. It includes:

  • KindClusterResource — core Aspire resource implementing IResourceWithConnectionString
  • KindClusterLifecycleHook — IDistributedApplicationLifecycleHook that creates/destroys the cluster
  • KindClusterExtensions — fluent API extension methods (AddKindCluster, AddDeployment, AddService, etc.)
  • KubernetesManifestResource — child resource representing k8s manifests deployed to the cluster
  • Full integration tests using DistributedApplicationTestingBuilder
  • XML documentation and usage samples

The implementation uses the kind CLI (must be installed) and wraps it via CliWrap. It was tested on Linux and Windows.

Prior Art / Related

  • Aspire.Hosting.Docker — similar pattern for Docker resources
  • Aspire's container model uses a similar lifecycle pattern for container resources

Contribution Plan

If maintainers are open to this, I am happy to:

  1. Fork and adapt the implementation to match CommunityToolkit conventions
  2. Add tests following the project's test patterns
  3. Write samples following the existing sample structure
  4. Submit a PR with full documentation

Co-authored with Andrey Noskov.

Questions for Maintainers

  • Is this the kind of resource the CommunityToolkit/Aspire project is interested in hosting?
  • Should we align the API with any existing conventions I may have missed?
  • Any concerns about requiring kind CLI as a prerequisite (similar to Docker CLI dependency)?

Happy to discuss and iterate before submitting a PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions