İçeriğe geç
Docs Try Aspire

Kubernetes integration

Bu içerik henüz dilinizde mevcut değil.

Kubernetes logo

The Aspire Kubernetes hosting integration enables you to generate Kubernetes deployment manifests from your Aspire application model. This integration allows you to define your application’s infrastructure and deployment configuration using the familiar Aspire AppHost and then publish it as Kubernetes YAML manifests for deployment to any Kubernetes cluster.

To get started with the Aspire Kubernetes hosting integration, install the 📦 Aspire.Hosting.Kubernetes NuGet package in the AppHost project:

Aspire CLI — Aspire.Hosting.Kubernetes paketi ekle
aspire add kubernetes

Aspire CLI etkileşimlidir; istendiğinde uygun sonucu seçin:

Aspire CLI — Örnek çıktı
Select an integration to add:
> kubernetes (Aspire.Hosting.Kubernetes)
> Other results listed as selectable options...

After installing the package, add a Kubernetes environment to your AppHost project using the AddKubernetesEnvironment method:

C# — AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var k8s = builder.AddKubernetesEnvironment("k8s");
var api = builder.AddProject<Projects.MyApi>("api");
builder.Build().Run();

Configure Kubernetes environment properties

Section titled “Configure Kubernetes environment properties”

You can customize the Kubernetes environment using the WithProperties method:

C# — AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var api = builder.AddProject<Projects.MyApi>("api");
builder.AddKubernetesEnvironment("k8s")
.WithProperties(k8s =>
{
k8s.HelmChartName = "my-aspire-app";
});
builder.Build().Run();

The WithProperties method allows you to configure various aspects of the Kubernetes deployment, including the Helm chart name that will be used for generating the Kubernetes resources.

For a complete guide on generating Kubernetes Helm charts, deploying with Helm, resource mappings, and troubleshooting — see Deploy to Kubernetes.