Skip to content
DocsTry Aspire
DocsTry

K3sManifestBuilderExtensions Methods

ClassMethods1 member
Extension methods for applying Kubernetes YAML manifests to a k3s cluster.
AddK8sManifest(IResourceBuilder<K3sClusterResource>, string, string)Section titled AddK8sManifest(IResourceBuilder<K3sClusterResource>, string, string)extensionIResourceBuilder<K8sManifestResource>
Applies Kubernetes YAML manifests or a Kustomize overlay to the cluster.
public static class K3sManifestBuilderExtensions
{
public static IResourceBuilder<K8sManifestResource> AddK8sManifest(
this IResourceBuilder<K3sClusterResource> builder,
string name,
string path)
{
// ...
}
}
builderIResourceBuilder<K3sClusterResource>The k3s cluster resource builder.
namestringThe Aspire resource name for this manifest application.
pathstring Path 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.
IResourceBuilder<K8sManifestResource>A builder for the K8sManifestResource.
ArgumentNullExceptionbuilder, name, or path is null.

The apply mode is detected automatically from path:

  • Single file — applied with kubectl apply -f.
  • Directory (no kustomization.yaml) — all .yaml / .yml files in the directory are applied with kubectl apply -f.
  • Kustomize overlay (directory contains kustomization.yaml or kustomization.yml) — applied with kubectl apply -k. The directory is bind-mounted so that relative references to base manifests are preserved.

The container exits with code 0 after all manifests are applied and any CRDs have reached the Established condition. No host-side kubectl binary is required. Use WaitForCompletion(manifest) on resources that must start only after the manifests are applied.