Arkanis.Aspire.Hosting.Extensions.Kubernetes 1.0.0-dev.7

This is a prerelease version of Arkanis.Aspire.Hosting.Extensions.Kubernetes.
dotnet add package Arkanis.Aspire.Hosting.Extensions.Kubernetes --version 1.0.0-dev.7
                    
NuGet\Install-Package Arkanis.Aspire.Hosting.Extensions.Kubernetes -Version 1.0.0-dev.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Arkanis.Aspire.Hosting.Extensions.Kubernetes" Version="1.0.0-dev.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Arkanis.Aspire.Hosting.Extensions.Kubernetes" Version="1.0.0-dev.7" />
                    
Directory.Packages.props
<PackageReference Include="Arkanis.Aspire.Hosting.Extensions.Kubernetes" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Arkanis.Aspire.Hosting.Extensions.Kubernetes --version 1.0.0-dev.7
                    
#r "nuget: Arkanis.Aspire.Hosting.Extensions.Kubernetes, 1.0.0-dev.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Arkanis.Aspire.Hosting.Extensions.Kubernetes@1.0.0-dev.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Arkanis.Aspire.Hosting.Extensions.Kubernetes&version=1.0.0-dev.7&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Arkanis.Aspire.Hosting.Extensions.Kubernetes&version=1.0.0-dev.7&prerelease
                    
Install as a Cake Tool

Arkanis.Aspire.Hosting.Extensions.Kubernetes

NuGet License

Shared .NET Aspire hosting extensions for Kubernetes publishing. This package contains manifest and YAML infrastructure, ingress helpers, PersistentVolumeClaim helpers, environment variables, Kubernetes connection-string secret references, and deployment-target selection.

Installation

dotnet add package Arkanis.Aspire.Hosting.Extensions.Kubernetes

Quick Start

using Aspire.Hosting;
using Aspire.Hosting.Extensions.Kubernetes;
using Aspire.Hosting.Extensions.Kubernetes.KubernetesConnections;
using Aspire.Hosting.Extensions.Kubernetes.KubernetesIngresses;
using Aspire.Hosting.Extensions.Kubernetes.PersistentVolumeClaims;

var builder = DistributedApplication.CreateBuilder(args);

var api = builder.AddProject<Projects.Api>("api");
var kubernetes = builder.AddKubernetesEnvironment("kubernetes");

api.WithKubernetesEnvironmentVariables(env =>
    env.WithConfigurationFrom(builder.Configuration));

api.WithKubernetesIngress(ingress =>
    ingress
        .AtHost("api.example.test")
        .AtPath("/", "Prefix")
        .UsingIngressClass("nginx")
        .InKubernetesEnvironment(kubernetes));

api.WithNewKubernetesPersistentVolumeClaim(
    "data",
    "api-data",
    "/var/lib/api",
    claim => claim
        .WithStorageRequest("10Gi")
        .WithReadWriteOnce()
        .WithStorageClass("fast"));

api.WithExistingKubernetesPersistentVolumeClaim(
    "shared-cache",
    "existing-cache",
    "/mnt/cache",
    readOnly: true);

builder.Build().Run();

WithKubernetesIngress(...) emits the Ingress manifest during Kubernetes publish. UseNewClaim(...) and WithNewKubernetesPersistentVolumeClaim(...) emit standalone PersistentVolumeClaim manifests during Kubernetes publish. Existing-claim APIs only add workload mounts and require the claim to exist or be declared elsewhere.

Use AddKubernetesIngressesFromResourceAnnotations() and WithPersistentVolumeClaims(...) only for legacy AppHosts or environment-wide manifests. Use WithKubernetesPersistentVolumeClaim(...) when a PVC mount needs configuration binding or an explicit Kubernetes environment.

Traefik Error Page Fallbacks

Use WithTraefikErrorPageFallback(...) on a resource-local Ingress when Traefik should serve a static fallback page for selected upstream errors. This emits a Traefik Middleware CRD and attaches it to the generated Kubernetes Ingress with traefik.ingress.kubernetes.io/router.middlewares.

var fallbackPages = builder.AddTraefikErrorPageFallbackPages(
    "fallback-pages",
    kubernetes,
    "../fallback-pages");

api.WithKubernetesIngress(ingress => ingress
    .AtHost("api.example.test")
    .UsingIngressClass("traefik")
    .InKubernetesEnvironment(kubernetes)
    .WithTraefikErrorPageFallback(fallbackPages, "apps", fallback => fallback
        .WithMiddlewareName("api-fallback-errors")
        .HandlingStatus("502", "503", "504")
        .Serving("/{status}.html")
        .ForwardingNoRequestHeaders()));

The fallback Service and static file container are owned by the library helper. The consumer provides the page source paths to mount into the container. Use the builder overload when you need to change the image, endpoint, port, or mounted destination path. The integrated overload adds the Traefik Middleware custom resource to that fallback service's Kubernetes AdditionalResources. Use TraefikErrorsMiddleware.Create(...) directly when you need to add the custom resource yourself inside PublishAsKubernetesService(...). Traefik must have its CRDs installed, and its Kubernetes Ingress provider must allow empty services when this is used for no-ready-endpoint outages. For Traefik Helm values, that means providers.kubernetesIngress.allowEmptyServices=true.

Configuration Examples

Resource-local builders can read deployment details from AppHost configuration. Ingress binding reads Kubernetes:Ingress:Resources:{ResourceName}:{IngressName} plus shared ingress defaults.

api.WithKubernetesIngress("api", ingress => ingress
    .WithConfigurationFrom(builder.Configuration)
    .InKubernetesEnvironment(kubernetes));

PVC mount binding reads Kubernetes:Volumes:Resources:{ResourceName}:{VolumeName}. It binds the claim name, mount path, and read-only flag for an existing claim.

api.WithKubernetesPersistentVolumeClaim("data", volume => volume
    .WithConfigurationFrom(builder.Configuration)
    .InKubernetesEnvironment(kubernetes));

When application resources are selected by deployment target, use ConfigureAny(...) to apply shared resource extensions to the active project-backed or container-backed resource.

using Aspire.Hosting.Extensions.Kubernetes.Targeting;

var targetedResources = new TargetedResourceFactory(useContainerResource: true);
var api = targetedResources.AddTargetedApplicationResource(
    () => builder.AddProject<Projects.Api>("api"),
    () => builder.AddContainer("api", "ghcr.io/example/api:latest"));

api.ConfigureAny(resource => resource
    .WithKubernetesEnvironmentVariables(env => env.WithConfigurationFrom(builder.Configuration)));

Secret Reload Restarts

WithKubernetesConnectionString(...) rewrites generated connection-string environment variables to use Kubernetes secretKeyRef values. When it does that, the generated Deployment metadata receives reloader.stakater.com/auto: "true" so Stakater Reloader can roll the workload after the referenced Secret changes.

web.WithKubernetesConnectionString(postgres, "ApplicationDatabase");

web.WithoutSecretReloadRestart();

Use WithoutSecretReloadRestart() only for workloads that must not restart automatically after a referenced Kubernetes Secret rotates.

Scope

This package records Kubernetes publishing intent in the Aspire AppHost model. It does not install a Kubernetes cluster, ingress controller, storage class, operator, CRD, or live-cluster resource.

  • Arkanis.Aspire.Hosting.Extensions.Kubernetes.ExternalSecrets adds External Secrets Operator helpers.
  • Arkanis.Aspire.Hosting.Extensions.Kubernetes.Tailscale adds Tailscale Kubernetes Operator helpers.
  • Arkanis.Aspire.Hosting.Extensions.Kubernetes.CloudNativePostgres adds CloudNativePG helpers.

Repository

Source, issues, and release workflow details are available at https://github.com/ArkanisCorporation/Aspire.Hosting.Extensions.Kubernetes.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Arkanis.Aspire.Hosting.Extensions.Kubernetes:

Package Downloads
Arkanis.Aspire.Hosting.Extensions.Kubernetes.ExternalSecrets

Reusable Aspire hosting extensions for publishing External Secrets Operator manifests from Kubernetes and Aspire Secret configuration.

Arkanis.Aspire.Hosting.Extensions.Kubernetes.CloudNativePostgres

Reusable Aspire hosting extensions for publishing CloudNativePG database resources and credentials ExternalSecrets.

Arkanis.Aspire.Hosting.Extensions.Kubernetes.Tailscale

Reusable Aspire hosting extensions for publishing Tailscale Kubernetes Operator services, ingresses, proxy classes, proxy groups, and policies.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-dev.7 132 7/5/2026
1.0.0-dev.6 70 7/5/2026
1.0.0-dev.5 102 7/4/2026
1.0.0-dev.4 93 7/3/2026
1.0.0-dev.3 85 7/2/2026
1.0.0-dev.2 308 6/16/2026
1.0.0-dev.1 99 6/11/2026