Install external Helm charts
Цей контент ще не доступний вашою мовою.
Install pre-existing Helm charts — such as cert-manager, NGINX ingress controller, or monitoring tools — as part of your Aspire Kubernetes deployment. Aspire runs helm upgrade --install for each configured external chart after deploying your application’s own generated Helm chart.
For the core Kubernetes deployment setup, see Deploy to Kubernetes clusters or Deploy to AKS.
Deployment order
Section titled “Deployment order”When you use aspire deploy, Aspire deploys your application as a Helm chart and then runs any additional install steps you have defined. AddHelmChart registers one of these post-deploy pipeline steps. The install order is:
- Aspire generates and deploys your application’s own Helm chart (
helm-deploy-{environment}). - Each external chart registered with
AddHelmChartis installed viahelm upgrade --install(helm-install-{name}).
Add an external Helm chart
Section titled “Add an external Helm chart”Add the chart to a Kubernetes or AKS environment resource, passing the chart name (used as both the resource name and the default Helm release name), a chart reference, and a chart version:
var builder = DistributedApplication.CreateBuilder(args);
var k8s = builder.AddKubernetesEnvironment("k8s");
k8s.AddHelmChart("cert-manager", "oci://quay.io/jetstack/charts/cert-manager", "1.17.0");
var api = builder.AddProject<Projects.MyApi>("api");
builder.Build().Run();import { function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder } from './.aspire/modules/aspire.mjs';
const const builder: IDistributedApplicationBuilder
builder = await function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder();
const const k8s: KubernetesEnvironmentResource
k8s = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addKubernetesEnvironment(name: string): KubernetesEnvironmentResource
Adds a Kubernetes environment to the application model.
addKubernetesEnvironment('k8s');
await const k8s: KubernetesEnvironmentResource
k8s.KubernetesEnvironmentResource.addHelmChart(name: string, chartReference: string, chartVersion: string): KubernetesHelmChartResource
Adds an external Helm chart to be installed in the Kubernetes environment. The chart is installed via helm upgrade --install as a pipeline step after the main application Helm chart is deployed.
addHelmChart( 'cert-manager', 'oci://quay.io/jetstack/charts/cert-manager', '1.17.0');
const const api: ProjectResource
api = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: { launchProfileOrOptions?: ProjectResourceOptions;}): ProjectResource (+1 overload)
Adds a .NET project resource
addProject('api', '../MyApi/MyApi.csproj');
await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.build(): DistributedApplication
Builds the distributed application
build().DistributedApplication.run(cancellationToken?: cancellationToken): void
Runs the distributed application
run();The chartReference parameter accepts:
- OCI URLs —
oci://registry.example.com/repo/chart - HTTP(S) URLs —
https://charts.example.com/chart-1.0.0.tgz - Local paths —
./charts/my-chart - Packaged
.tgzfilenames —my-chart-1.0.0.tgz - Repository-qualified names —
stable/nginx-ingress
Pass the chart version string expected by the chart repository, such as 1.17.0 or v1.18.2.
Configure Helm values
Section titled “Configure Helm values”Set Helm values to pass --set key=value arguments to the Helm install command:
k8s.AddHelmChart("cert-manager", "oci://quay.io/jetstack/charts/cert-manager", "1.17.0") .WithHelmValue("crds.enabled", "true") .WithHelmValue("config.enableGatewayAPI", "true");import { function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder } from './.aspire/modules/aspire.mjs';
const const builder: IDistributedApplicationBuilder
builder = await function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder();
const const k8s: KubernetesEnvironmentResource
k8s = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addKubernetesEnvironment(name: string): KubernetesEnvironmentResource
Adds a Kubernetes environment to the application model.
addKubernetesEnvironment('k8s');
const const certManager: KubernetesHelmChartResource
certManager = await const k8s: KubernetesEnvironmentResource
k8s.KubernetesEnvironmentResource.addHelmChart(name: string, chartReference: string, chartVersion: string): KubernetesHelmChartResource
Adds an external Helm chart to be installed in the Kubernetes environment. The chart is installed via helm upgrade --install as a pipeline step after the main application Helm chart is deployed.
addHelmChart( 'cert-manager', 'oci://quay.io/jetstack/charts/cert-manager', '1.17.0');
await const certManager: KubernetesHelmChartResource
certManager.KubernetesHelmChartResource.withHelmValue(key: string, value: string): KubernetesHelmChartResource
Sets a Helm value for the chart installation. Values are passed to helm upgrade --install via --set flags.
withHelmValue('crds.enabled', 'true');await const certManager: KubernetesHelmChartResource
certManager.KubernetesHelmChartResource.withHelmValue(key: string, value: string): KubernetesHelmChartResource
Sets a Helm value for the chart installation. Values are passed to helm upgrade --install via --set flags.
withHelmValue('config.enableGatewayAPI', 'true');Value keys support dot-notation (config.enableGatewayAPI) and indexed array paths (args[0]). Values are passed to Helm with --set flags.
Configure the namespace and release name
Section titled “Configure the namespace and release name”By default, the chart is installed in a namespace named after the chart resource and uses the chart resource name as the Helm release name. Override these in your AppHost when you need a different namespace or release name:
k8s.AddHelmChart("ingress-nginx", "oci://ghcr.io/nginx/helm/nginx-ingress", "2.0.0") .WithNamespace("ingress-nginx") .WithReleaseName("ingress-nginx");import { function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder } from './.aspire/modules/aspire.mjs';
const const builder: IDistributedApplicationBuilder
builder = await function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder();
const const k8s: KubernetesEnvironmentResource
k8s = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addKubernetesEnvironment(name: string): KubernetesEnvironmentResource
Adds a Kubernetes environment to the application model.
addKubernetesEnvironment('k8s');
const const ingressNginx: KubernetesHelmChartResource
ingressNginx = await const k8s: KubernetesEnvironmentResource
k8s.KubernetesEnvironmentResource.addHelmChart(name: string, chartReference: string, chartVersion: string): KubernetesHelmChartResource
Adds an external Helm chart to be installed in the Kubernetes environment. The chart is installed via helm upgrade --install as a pipeline step after the main application Helm chart is deployed.
addHelmChart( 'ingress-nginx', 'oci://ghcr.io/nginx/helm/nginx-ingress', '2.0.0');
await const ingressNginx: KubernetesHelmChartResource
ingressNginx.KubernetesHelmChartResource.withHelmChartNamespace(namespace: string): KubernetesHelmChartResource
Sets the Kubernetes namespace for the Helm chart installation. If not set, the namespace defaults to the chart resource name.
withHelmChartNamespace('ingress-nginx');await const ingressNginx: KubernetesHelmChartResource
ingressNginx.KubernetesHelmChartResource.withHelmChartReleaseName(releaseName: string): KubernetesHelmChartResource
Sets the Helm release name for the chart installation. If not set, the release name defaults to the resource name.
withHelmChartReleaseName('ingress-nginx');- Namespace overrides must follow RFC 1123 DNS label rules (lowercase alphanumerics and hyphens, max 63 characters).
- Release name overrides must follow Helm’s release-name rules (DNS label format, max 53 characters).
Uninstall on destroy
Section titled “Uninstall on destroy”By default, external charts are not uninstalled when you run aspire destroy. This is intentional: cluster-wide tools such as cert-manager or monitoring agents are often shared by multiple workloads and shouldn’t be torn down when a single application is removed.
To opt in to uninstall-on-destroy, enable destroy-time uninstall in your AppHost:
k8s.AddHelmChart("podinfo", "oci://ghcr.io/stefanprodan/charts/podinfo", "6.7.1") .WithHelmValue("replicaCount", "2") .WithDestroy();import { function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder } from './.aspire/modules/aspire.mjs';
const const builder: IDistributedApplicationBuilder
builder = await function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder();
const const k8s: KubernetesEnvironmentResource
k8s = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addKubernetesEnvironment(name: string): KubernetesEnvironmentResource
Adds a Kubernetes environment to the application model.
addKubernetesEnvironment('k8s');
const const podinfo: KubernetesHelmChartResource
podinfo = await const k8s: KubernetesEnvironmentResource
k8s.KubernetesEnvironmentResource.addHelmChart(name: string, chartReference: string, chartVersion: string): KubernetesHelmChartResource
Adds an external Helm chart to be installed in the Kubernetes environment. The chart is installed via helm upgrade --install as a pipeline step after the main application Helm chart is deployed.
addHelmChart( 'podinfo', 'oci://ghcr.io/stefanprodan/charts/podinfo', '6.7.1');
await const podinfo: KubernetesHelmChartResource
podinfo.KubernetesHelmChartResource.withHelmValue(key: string, value: string): KubernetesHelmChartResource
Sets a Helm value for the chart installation. Values are passed to helm upgrade --install via --set flags.
withHelmValue('replicaCount', '2');await const podinfo: KubernetesHelmChartResource
podinfo.KubernetesHelmChartResource.withHelmChartDestroy(): KubernetesHelmChartResource
Opts the Helm chart in to destroy-time uninstall. When set, aspire destroy will run helm uninstall for this release as part of the destroy pipeline.
withHelmChartDestroy();When destroy-time uninstall is enabled, aspire destroy runs helm uninstall for the chart in addition to removing your application’s resources.
Deploy to AKS
Section titled “Deploy to AKS”The same AddHelmChart API is available on AKS environments through the Aspire.Hosting.Azure.Kubernetes package:
var builder = DistributedApplication.CreateBuilder(args);
var aks = builder.AddAzureKubernetesEnvironment("aks");
aks.AddHelmChart("podinfo", "oci://ghcr.io/stefanprodan/charts/podinfo", "6.7.1") .WithHelmValue("replicaCount", "2") .WithDestroy();
var api = builder.AddProject<Projects.MyApi>("api");
builder.Build().Run();import { function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder } from './.aspire/modules/aspire.mjs';
const const builder: IDistributedApplicationBuilder
builder = await function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder();
const const aks: AzureKubernetesEnvironmentResource
aks = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addAzureKubernetesEnvironment(name: string): AzureKubernetesEnvironmentResource
Adds an Azure Kubernetes Service (AKS) environment to the distributed application. This provisions an AKS cluster and configures it as a Kubernetes compute environment.
addAzureKubernetesEnvironment('aks');
const const podinfo: KubernetesHelmChartResource
podinfo = await const aks: AzureKubernetesEnvironmentResource
aks.AzureKubernetesEnvironmentResource.addHelmChart(name: string, chartReference: string, chartVersion: string): KubernetesHelmChartResource
Adds an external Helm chart to be installed in the AKS environment's inner Kubernetes environment. The chart is installed via helm upgrade --install as a pipeline step after the main application Helm chart is deployed.
addHelmChart( 'podinfo', 'oci://ghcr.io/stefanprodan/charts/podinfo', '6.7.1');await const podinfo: KubernetesHelmChartResource
podinfo.KubernetesHelmChartResource.withHelmValue(key: string, value: string): KubernetesHelmChartResource
Sets a Helm value for the chart installation. Values are passed to helm upgrade --install via --set flags.
withHelmValue('replicaCount', '2');await const podinfo: KubernetesHelmChartResource
podinfo.KubernetesHelmChartResource.withHelmChartDestroy(): KubernetesHelmChartResource
Opts the Helm chart in to destroy-time uninstall. When set, aspire destroy will run helm uninstall for this release as part of the destroy pipeline.
withHelmChartDestroy();
const const api: ProjectResource
api = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: { launchProfileOrOptions?: ProjectResourceOptions;}): ProjectResource (+1 overload)
Adds a .NET project resource
addProject('api', '../MyApi/MyApi.csproj');
await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.build(): DistributedApplication
Builds the distributed application
build().DistributedApplication.run(cancellationToken?: cancellationToken): void
Runs the distributed application
run();The AKS environment delegates external chart installation to its inner Kubernetes environment, so the same Helm value, namespace, release name, and destroy-time uninstall options apply.
Complete example
Section titled “Complete example”The following example installs cert-manager and a custom podinfo chart alongside an Aspire application on Kubernetes:
var builder = DistributedApplication.CreateBuilder(args);
var k8s = builder.AddKubernetesEnvironment("k8s");
// cert-manager is a cluster-wide tool — don't uninstall it when the app is destroyedk8s.AddHelmChart("cert-manager", "oci://quay.io/jetstack/charts/cert-manager", "1.17.0") .WithHelmValue("crds.enabled", "true");
// podinfo is specific to this app — uninstall it on destroyk8s.AddHelmChart("podinfo", "oci://ghcr.io/stefanprodan/charts/podinfo", "6.7.1") .WithNamespace("podinfo") .WithHelmValue("replicaCount", "2") .WithDestroy();
var api = builder.AddProject<Projects.MyApi>("api");
builder.Build().Run();import { function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder } from './.aspire/modules/aspire.mjs';
const const builder: IDistributedApplicationBuilder
builder = await function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder();
const const k8s: KubernetesEnvironmentResource
k8s = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addKubernetesEnvironment(name: string): KubernetesEnvironmentResource
Adds a Kubernetes environment to the application model.
addKubernetesEnvironment('k8s');
// cert-manager is a cluster-wide tool — don't uninstall it when the app is destroyedconst const certManager: KubernetesHelmChartResource
certManager = await const k8s: KubernetesEnvironmentResource
k8s.KubernetesEnvironmentResource.addHelmChart(name: string, chartReference: string, chartVersion: string): KubernetesHelmChartResource
Adds an external Helm chart to be installed in the Kubernetes environment. The chart is installed via helm upgrade --install as a pipeline step after the main application Helm chart is deployed.
addHelmChart( 'cert-manager', 'oci://quay.io/jetstack/charts/cert-manager', '1.17.0');await const certManager: KubernetesHelmChartResource
certManager.KubernetesHelmChartResource.withHelmValue(key: string, value: string): KubernetesHelmChartResource
Sets a Helm value for the chart installation. Values are passed to helm upgrade --install via --set flags.
withHelmValue('crds.enabled', 'true');
// podinfo is specific to this app — uninstall it on destroyconst const podinfo: KubernetesHelmChartResource
podinfo = await const k8s: KubernetesEnvironmentResource
k8s.KubernetesEnvironmentResource.addHelmChart(name: string, chartReference: string, chartVersion: string): KubernetesHelmChartResource
Adds an external Helm chart to be installed in the Kubernetes environment. The chart is installed via helm upgrade --install as a pipeline step after the main application Helm chart is deployed.
addHelmChart( 'podinfo', 'oci://ghcr.io/stefanprodan/charts/podinfo', '6.7.1');await const podinfo: KubernetesHelmChartResource
podinfo.KubernetesHelmChartResource.withHelmChartNamespace(namespace: string): KubernetesHelmChartResource
Sets the Kubernetes namespace for the Helm chart installation. If not set, the namespace defaults to the chart resource name.
withHelmChartNamespace('podinfo');await const podinfo: KubernetesHelmChartResource
podinfo.KubernetesHelmChartResource.withHelmValue(key: string, value: string): KubernetesHelmChartResource
Sets a Helm value for the chart installation. Values are passed to helm upgrade --install via --set flags.
withHelmValue('replicaCount', '2');await const podinfo: KubernetesHelmChartResource
podinfo.KubernetesHelmChartResource.withHelmChartDestroy(): KubernetesHelmChartResource
Opts the Helm chart in to destroy-time uninstall. When set, aspire destroy will run helm uninstall for this release as part of the destroy pipeline.
withHelmChartDestroy();
const const api: ProjectResource
api = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: { launchProfileOrOptions?: ProjectResourceOptions;}): ProjectResource (+1 overload)
Adds a .NET project resource
addProject('api', '../MyApi/MyApi.csproj');
await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.build(): DistributedApplication
Builds the distributed application
build().DistributedApplication.run(cancellationToken?: cancellationToken): void
Runs the distributed application
run();