K3sClusterResource

Handle
📦 CommunityToolkit.Aspire.Hosting.K3s v13.6.1
interface K3sClusterResource
extends IComputeResource,
IExpressionValue,
IManifestExpressionProvider,
IResource,
IResourceWithArgs,
IResourceWithConnectionString,
IResourceWithEndpoints,
IResourceWithEnvironment,
IResourceWithProbes,
IResourceWithWaitSupport,
IValueProvider,
IValueWithReferences {
readonly apiEndpoint: EndpointReference;
readonly connectionStringEnvironmentVariable: string;
readonly connectionStringExpression: ReferenceExpression;
addHelmRelease(
name: string,
chart: string,
repo?: string,
version?: string,
namespace?: string): HelmReleaseResource;
addK8sManifest(
name: string,
path: string): K8sManifestResource;
addServiceEndpoint(
name: string,
serviceName: string,
servicePort: number,
namespace?: string,
scheme?: string): K3sServiceEndpointResource;
withAgentCount(count: number): K3sClusterResource;
withDataVolume(name?: string): K3sClusterResource;
withDisabledComponent(component: string): K3sClusterResource;
withExtraArg(arg: string): K3sClusterResource;
withHelmImage(
tag?: string,
image?: string,
registry?: string): K3sClusterResource;
withK3sVersion(tag: string): K3sClusterResource;
withKubectlImage(
tag?: string,
image?: string,
registry?: string): K3sClusterResource;
withLifetime(lifetime: ContainerLifetime): K3sClusterResource;
withPodSubnet(cidr: string): K3sClusterResource;
withServiceSubnet(cidr: string): K3sClusterResource;
}

Properties

propertyapiEndpointEndpointReferenceget
Gets the endpoint reference for the k3s API server (port 6443).
propertyconnectionStringEnvironmentVariablestringget
Overrides the default `ConnectionStrings__` prefix so Aspire injects `KUBECONFIG`.
propertyconnectionStringExpressionReferenceExpressionget
Manifest expression for the local kubeconfig path.

Methods

methodaddHelmReleasebuilder
Installs a Helm chart into the k3s cluster.
addHelmRelease(
name: string,
chart: string,
repo?: string,
version?: string,
namespace?: string): HelmReleaseResource
namestringThe Aspire resource name; also used as the Helm release name passed to `helm upgrade --install`.
chartstringThe chart name, e.g. `argo-cd` for a repo chart or `oci://registry/chart` for an OCI reference. Provide `repo` when using a named repo chart.
repostringoptionalOptional Helm repository URL, e.g. `https://argoproj.github.io/argo-helm`. When provided, the repo is added and updated before installation.
versionstringoptionalOptional chart version to pin, e.g. `7.8.0`. When `null` the latest version available in the repository is installed.
namespacestringoptional= defaultThe Kubernetes namespace to install the release into. The namespace is created automatically if it does not exist. Defaults to `default`.
HelmReleaseResource
methodaddK8sManifestbuilder
Applies Kubernetes YAML manifests or a Kustomize overlay to the cluster.
addK8sManifest(
name: string,
path: string): K8sManifestResource
namestringThe Aspire resource name for this manifest application.
pathstringPath to a single `.yaml`/`.yml` file, a directory of YAML files, or a Kustomize overlay directory (containing `kustomization.yaml`). Relative paths are resolved against the AppHost project directory.
K8sManifestResource
methodaddServiceEndpointbuilder
Exposes a Kubernetes Service from the cluster as an Aspire endpoint resource.
addServiceEndpoint(
name: string,
serviceName: string,
servicePort: number,
namespace?: string,
scheme?: string): K3sServiceEndpointResource
namestringThe Aspire resource name for this endpoint.
serviceNamestringThe name of the Kubernetes Service to forward, as it appears in `kubectl get svc`.
servicePortnumberThe port number declared on the Kubernetes Service (the `port` field, not `targetPort`). Must be in the range 1–65535.
namespacestringoptional= defaultThe Kubernetes namespace that contains the Service. Defaults to `default`.
schemestringoptionalThe URL scheme (`http` or `https`) for the injected environment variable. When `null` (the default), the scheme is inferred from the port: ports 443 and 8443 use `https`, all others use `http`.
K3sServiceEndpointResource
methodwithAgentCountbuilder
Sets the number of k3s agent (worker) nodes to add to the cluster.
withAgentCount(count: number): K3sClusterResource
countnumberThe number of agent nodes. Zero or greater. Defaults to `0` (single-node cluster — the server node acts as both control-plane and worker).
K3sClusterResource
methodwithDataVolumebuilder
Mounts a named Docker volume at the k3s data directory so cluster state persists across AppHost restarts.
withDataVolume(name?: string): K3sClusterResource
namestringoptionalOptional volume name. When `null` (the default) a name is generated from the application and resource names.
K3sClusterResource
Disables a built-in k3s component (`--disable=<component>`).
withDisabledComponent(component: string): K3sClusterResource
componentstringThe component name to disable. Common values include `traefik`, `servicelb`, `metrics-server`, `coredns`, and `local-storage`. Call this method multiple times to disable more than one component.
K3sClusterResource
methodwithExtraArgbuilder
Appends a raw argument to the `k3s server` command line.
withExtraArg(arg: string): K3sClusterResource
argstringThe raw argument to append, e.g. `--write-kubeconfig-mode=644`. Call this method multiple times to append additional arguments.
K3sClusterResource
methodwithHelmImagebuilder
Overrides the container image used to run `helm upgrade --install` for all `HelmReleaseResource` children of this cluster.
withHelmImage(
tag?: string,
image?: string,
registry?: string): K3sClusterResource
tagstringoptionalImage tag, e.g. `3.18.0`. `null` keeps the current value.
imagestringoptionalImage name, e.g. `alpine/helm`. `null` keeps the current value.
registrystringoptionalRegistry, e.g. `docker.io`. `null` keeps the current value.
K3sClusterResource
methodwithK3sVersionbuilder
Sets the k3s image version used by the cluster server and all its agent nodes.
withK3sVersion(tag: string): K3sClusterResource
tagstringThe k3s container image tag, e.g. `v1.32.3-k3s1`. Must follow the `v{major}.{minor}.{patch}-k3s{n}` format.
K3sClusterResource
methodwithKubectlImagebuilder
Overrides the container image used to run `kubectl apply` for all `K8sManifestResource` children of this cluster.
withKubectlImage(
tag?: string,
image?: string,
registry?: string): K3sClusterResource
tagstringoptionalImage tag, e.g. `1.37.0`. `null` keeps the current value.
imagestringoptionalImage name, e.g. `alpine/kubectl`. `null` keeps the current value.
registrystringoptionalRegistry, e.g. `docker.io`. `null` keeps the current value.
K3sClusterResource
methodwithLifetimebuilder
Sets the container lifetime for the k3s cluster and all its agent nodes.
withLifetime(lifetime: ContainerLifetime): K3sClusterResource
lifetimeContainerLifetimeThe container lifetime to apply.
K3sClusterResource
methodwithPodSubnetbuilder
Sets the CIDR range for pod IP addresses (`--cluster-cidr`).
withPodSubnet(cidr: string): K3sClusterResource
cidrstringThe pod subnet in CIDR notation, e.g. `10.42.0.0/16`.
K3sClusterResource
methodwithServiceSubnetbuilder
Sets the CIDR range for Service cluster IPs (`--service-cidr`).
withServiceSubnet(cidr: string): K3sClusterResource
cidrstringThe service subnet in CIDR notation, e.g. `10.43.0.0/16`.
K3sClusterResource