# K3sClusterResource

- Module: [CommunityToolkit.Aspire.Hosting.K3s](/reference/api/go/communitytoolkit.aspire.hosting.k3s.md)
- Version: `13.6.1`
- Kind: `handle`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/tree/d9c2addac6f527ef2e33712d290b84574b455a3b)

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

## Definition

```go
type K3sClusterResource interface {
    ExpressionValue
    IComputeResource
    Resource
    ResourceWithArgs
    ResourceWithConnectionString
    ResourceWithEndpoints
    ResourceWithEnvironment
    ResourceWithWaitSupport
}
```

## Embeds

- `ExpressionValue`
- `IComputeResource`
- `Resource`
- `ResourceWithArgs`
- `ResourceWithConnectionString`
- `ResourceWithEndpoints`
- `ResourceWithEnvironment`
- `ResourceWithWaitSupport`

## Properties

- `ApiEndpoint`: `EndpointReference` `get` -- Gets the endpoint reference for the k3s API server (port 6443).
- `ConnectionStringEnvironmentVariable`: `*string` `get` -- Overrides the default `ConnectionStrings__` prefix so Aspire injects `KUBECONFIG`.
- `ConnectionStringExpression`: `*ReferenceExpression` `get` -- Manifest expression for the local kubeconfig path.

## Methods

- [AddHelmRelease](/reference/api/go/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/addhelmrelease.md) -- `method` -- Installs a Helm chart into the k3s cluster.
  ```go
  AddHelmRelease(name string, chart string, options ...*AddHelmReleaseOptions) HelmReleaseResource
  ```
- [AddK8sManifest](/reference/api/go/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/addk8smanifest.md) -- `method` -- Applies Kubernetes YAML manifests or a Kustomize overlay to the cluster.
  ```go
  AddK8sManifest(name string, path string) K8sManifestResource
  ```
- [AddServiceEndpoint](/reference/api/go/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/addserviceendpoint.md) -- `method` -- Exposes a Kubernetes Service from the cluster as an Aspire endpoint resource.
  ```go
  AddServiceEndpoint(name string, serviceName string, servicePort float64, options ...*AddServiceEndpointOptions) K3sServiceEndpointResource
  ```
- [WithAgentCount](/reference/api/go/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/withagentcount.md) -- `method` -- Sets the number of k3s agent (worker) nodes to add to the cluster.
  ```go
  WithAgentCount(count float64) K3sClusterResource
  ```
- [WithDataVolume](/reference/api/go/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/withdatavolume.md) -- `method` -- Mounts a named Docker volume at the k3s data directory so cluster state persists across AppHost restarts.
  ```go
  WithDataVolume(options ...*WithDataVolumeOptions) K3sClusterResource
  ```
- [WithDisabledComponent](/reference/api/go/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/withdisabledcomponent.md) -- `method` -- Disables a built-in k3s component (`--disable=<component>`).
  ```go
  WithDisabledComponent(component string) K3sClusterResource
  ```
- [WithExtraArg](/reference/api/go/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/withextraarg.md) -- `method` -- Appends a raw argument to the `k3s server` command line.
  ```go
  WithExtraArg(arg string) K3sClusterResource
  ```
- [WithHelmImage](/reference/api/go/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/withhelmimage.md) -- `method` -- Overrides the container image used to run `helm upgrade --install` for all `HelmReleaseResource` children of this cluster.
  ```go
  WithHelmImage(options ...*WithHelmImageOptions) K3sClusterResource
  ```
- [WithK3sVersion](/reference/api/go/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/withk3sversion.md) -- `method` -- Sets the k3s image version used by the cluster server and all its agent nodes.
  ```go
  WithK3sVersion(tag string) K3sClusterResource
  ```
- [WithKubectlImage](/reference/api/go/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/withkubectlimage.md) -- `method` -- Overrides the container image used to run `kubectl apply` for all `K8sManifestResource` children of this cluster.
  ```go
  WithKubectlImage(options ...*WithKubectlImageOptions) K3sClusterResource
  ```
- [WithLifetime](/reference/api/go/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/withlifetime.md) -- `method` -- Sets the container lifetime for the k3s cluster and all its agent nodes.
  ```go
  WithLifetime(lifetime ContainerLifetime) K3sClusterResource
  ```
- [WithPodSubnet](/reference/api/go/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/withpodsubnet.md) -- `method` -- Sets the CIDR range for pod IP addresses (`--cluster-cidr`).
  ```go
  WithPodSubnet(cidr string) K3sClusterResource
  ```
- [WithServiceSubnet](/reference/api/go/communitytoolkit.aspire.hosting.k3s/k3sclusterresource/withservicesubnet.md) -- `method` -- Sets the CIDR range for Service cluster IPs (`--service-cidr`).
  ```go
  WithServiceSubnet(cidr string) K3sClusterResource
  ```
