# K3sClusterResource Methods

- Package: [CommunityToolkit.Aspire.Hosting.K3s](/reference/api/csharp/communitytoolkit.aspire.hosting.k3s.md)
- Type: [K3sClusterResource](/reference/api/csharp/communitytoolkit.aspire.hosting.k3s/k3sclusterresource.md)
- Kind: `Methods`
- Members: `1`

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`.

<a id="getconnectionstringasync"></a>
<a id="getconnectionstringasync-cancellationtoken"></a>

## GetConnectionStringAsync(CancellationToken)

- Name: `GetConnectionStringAsync(CancellationToken)`
- Returns: `ValueTask<string?>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d479e13473b1d29d06b974f144a0049289a3cb5c/src/CommunityToolkit.Aspire.Hosting.K3s/K3sClusterResource.cs#L61-L64)

Returns the host-accessible kubeconfig path for this cluster.

```csharp
public sealed class K3sClusterResource
{
    public ValueTask<string?> GetConnectionStringAsync(
        CancellationToken cancellationToken = default(CancellationToken))
    {
        // ...
    }
}
```

## Parameters

- `cancellationToken` (`CancellationToken`) `optional`
