Skip to content
DocsTry Aspire
DocsTry

K3sClusterResource

Handle
📦 CommunityToolkit.Aspire.Hosting.K3s v13.5.0
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
namestring
chartstring
repostringoptional
versionstringoptional
namespacestringoptional= default
HelmReleaseResource
methodaddK8sManifestbuilder
Applies Kubernetes YAML manifests or a Kustomize overlay to the cluster.
addK8sManifest(
name: string,
path: string): K8sManifestResource
namestring
pathstring
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
namestring
serviceNamestring
servicePortnumber
namespacestringoptional= default
schemestringoptional
K3sServiceEndpointResource
methodwithAgentCountbuilder
Sets the number of k3s agent (worker) nodes to add to the cluster.
withAgentCount(count: number): K3sClusterResource
countnumber
K3sClusterResource
methodwithDataVolumebuilder
Mounts a named Docker volume at the k3s data directory so cluster state persists across AppHost restarts.
withDataVolume(name?: string): K3sClusterResource
namestringoptional
K3sClusterResource
Disables a built-in k3s component (`--disable=<component>`).
withDisabledComponent(component: string): K3sClusterResource
componentstring
K3sClusterResource
methodwithExtraArgbuilder
Appends a raw argument to the `k3s server` command line.
withExtraArg(arg: string): K3sClusterResource
argstring
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
tagstringoptional
imagestringoptional
registrystringoptional
K3sClusterResource
methodwithK3sVersionbuilder
Sets the k3s image version used by the cluster server and all its agent nodes.
withK3sVersion(tag: string): K3sClusterResource
tagstring
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
tagstringoptional
imagestringoptional
registrystringoptional
K3sClusterResource
methodwithLifetimebuilder
Sets the container lifetime for the k3s cluster and all its agent nodes.
withLifetime(lifetime: ContainerLifetime): K3sClusterResource
lifetimeContainerLifetime
K3sClusterResource
methodwithPodSubnetbuilder
Sets the CIDR range for pod IP addresses (`--cluster-cidr`).
withPodSubnet(cidr: string): K3sClusterResource
cidrstring
K3sClusterResource
methodwithServiceSubnetbuilder
Sets the CIDR range for Service cluster IPs (`--service-cidr`).
withServiceSubnet(cidr: string): K3sClusterResource
cidrstring
K3sClusterResource