Este conteúdo não está disponível em sua língua ainda.
Deploy your Aspire application to any existing Kubernetes cluster. Aspire generates a complete Helm chart from your application model, and you can either apply it yourself or let aspire deploy install it directly using your current kubectl context.
var builder =DistributedApplication.CreateBuilder(args);
var k8s =builder.AddKubernetesEnvironment("k8s");
var api =builder.AddProject<Projects.MyApi>("api");
builder.Build().Run();
When a Kubernetes environment is present, all compute resources are automatically published as Kubernetes workloads — no additional opt-in is required.
Unlike managed targets such as AKS, a vanilla Kubernetes cluster doesn’t know which container registry to use for your application images. Without a registry, Aspire has no way to make your locally-built images available to cluster nodes. You must provide a container registry that is accessible from both your local machine (to push images) and from the cluster (to pull images):
var api =builder.AddProject<Projects.MyApi>("api");
builder.Build().Run();
The registry endpoint must be reachable from both your local machine and from the Kubernetes cluster nodes. When you run aspire deploy, Aspire builds your container images, pushes them to this registry, and configures the Helm chart to pull from it.
To deploy directly to your current Kubernetes cluster, use aspire deploy:
Deploy to Kubernetes
aspiredeploy
aspire deploy uses your current kubectl context and deploys the application using helm install. Aspire builds container images, generates the Helm chart, and installs it to the cluster in a single command.
For subsequent deployments, aspire deploy automatically upgrades the existing Helm release.
The publisher generates parameterized Helm values for container image references. If you haven’t specified custom container images, the generated values.yaml contains placeholders that you override at deployment time using --set or a custom values file.
When a parameter is embedded inside a larger environment variable expression — for example, a URL that contains a host parameter — the publisher declares the parameter as its own entry in values.yaml. The embedded parameter doesn’t become an extra environment variable; instead, the generated ConfigMap or Secret references it directly, so you can override just that value at deployment time without reconstructing the entire URL.
Use an Aspire reference expression for composition, not a TypeScript string interpolation of a resource handle:
The generated values.yaml declares both the composed environment value and the nested host parameter under the resource’s config section, and the ConfigMap template references the nested value:
When you deploy with aspire deploy, Aspire resolves each nested parameter and the composed expression using the parameter’s effective value — for example, SOME_URL becomes http://localhost/test. If you install the chart yourself, override the nested entry, such as --set config.myapp.host=example.com. Secret parameters are declared under secrets.<resource> instead, and any environment variable that embeds a secret parameter is emitted in the resource’s Secret rather than its ConfigMap.
Conflicting Helm value paths, including names that collide after normalization, fail publishing rather than overwriting another entry.
In Kubernetes, services discover each other using the cluster’s built-in DNS. A service named api is reachable at api.<namespace>.svc.cluster.local. The generated Helm charts configure service references automatically using Kubernetes-native DNS resolution.
If your application can’t find connection strings at runtime, verify that the generated ConfigMaps and Secrets are correctly mounted as environment variables in your pod specifications. Check that the resource names in your Helm values match the expected connection string names.
Kubernetes Secrets store values as base64-encoded strings. Verify that your Secrets are properly encoded and that the generated templates reference them correctly. Use kubectl get secret <name> -o yaml to inspect Secret contents.
Use AddHelmChart on the Kubernetes environment to install pre-existing Helm charts — such as cert-manager, NGINX ingress, or monitoring tools — as post-deploy pipeline steps alongside your application’s own chart.
See Install external Helm charts for a full walkthrough of adding external charts, configuring Helm values, overriding namespaces and release names, and choosing destroy-time uninstall behavior.