# K3sClusterResource

- Kind: `class`
- Package: [CommunityToolkit.Aspire.Hosting.K3s](/reference/api/csharp/communitytoolkit.aspire.hosting.k3s.md)
- Version: `13.4.1-beta.706`
- Namespace: `Aspire.Hosting.ApplicationModel`
- Target framework: `net10.0`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d479e13473b1d29d06b974f144a0049289a3cb5c/src/CommunityToolkit.Aspire.Hosting.K3s/K3sClusterResource.cs)
- Inherits: `ContainerResource`
- Implements: `IExpressionValue`, `IManifestExpressionProvider`, `IResource`, `IResourceWithConnectionString`, `IValueProvider`, `IValueWithReferences`

Represents a k3s Kubernetes cluster running as a privileged container resource. Injects the cluster's kubeconfig into a dependent resource.

- Host processes receive `KUBECONFIG=<host-path>/local/kubeconfig.yaml`.
- Containers receive `KUBECONFIG=/tmp/k3s-kubeconfig.yaml` and a file-level bind-mount of the container-network kubeconfig variant. Both are applied by the `BeforeStartEvent` subscriber registered in `AddK3sCluster`.

## Definition

```csharp
namespace Aspire.Hosting.ApplicationModel;

public sealed class K3sClusterResource
    : Aspire.Hosting.ApplicationModel.ContainerResource,
      Aspire.Hosting.ApplicationModel.IExpressionValue,
      Aspire.Hosting.ApplicationModel.IManifestExpressionProvider,
      Aspire.Hosting.ApplicationModel.IResource,
      Aspire.Hosting.ApplicationModel.IResourceWithConnectionString,
      Aspire.Hosting.ApplicationModel.IValueProvider,
      Aspire.Hosting.ApplicationModel.IValueWithReferences
{
    // ...
}
```

## ATS metadata

### ATS export

- Type ID: `CommunityToolkit.Aspire.Hosting.K3s/K3sClusterResource`
- Public instance properties are exported as ATS capabilities.

## Constructors

- [K3sClusterResource(string)](/reference/api/csharp/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/constructors.md#constructor-string) -- Represents a k3s Kubernetes cluster running as a privileged container resource. Injects the cluster's kubeconfig into a dependent resource. - Host processes receive `KUBECONFIG=<host-path>/local/kubeconfig.yaml`. - Containers receive `KUBECONFIG=/tmp/k3s-kubeconfig.yaml` and a file-level bind-mount of the container-network kubeconfig variant. Both are applied by the `BeforeStartEvent` subscriber registered in `AddK3sCluster`.

## Properties

- [ApiEndpoint](/reference/api/csharp/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/properties.md#apiendpoint) : `EndpointReference` `get` -- Gets the endpoint reference for the k3s API server (port 6443).
- [ConnectionStringEnvironmentVariable](/reference/api/csharp/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/properties.md#connectionstringenvironmentvariable) : `string?` `get` -- Overrides the default `ConnectionStrings__` prefix so Aspire injects `KUBECONFIG`.
- [ConnectionStringExpression](/reference/api/csharp/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/properties.md#connectionstringexpression) : `ReferenceExpression` `get` -- Manifest expression for the local kubeconfig path.
- [HelmReleases](/reference/api/csharp/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/properties.md#helmreleases) : `IReadOnlyDictionary<string, string>` `get` `ats ignored` -- A dictionary of registered Helm releases keyed by resource name.
- [Manifests](/reference/api/csharp/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/properties.md#manifests) : `IReadOnlyList<string>` `get` `ats ignored` -- Names of registered [K8sManifestResource](/reference/api/csharp/communitytoolkit.aspire.hosting.k3s/k8smanifestresource.md) children.

## Methods

- [GetConnectionStringAsync(CancellationToken)](/reference/api/csharp/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/methods.md#getconnectionstringasync-cancellationtoken) : `ValueTask<string?>` -- Returns the host-accessible kubeconfig path for this cluster.
