Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions src/frontend/src/content/docs/deployment/kubernetes-ingress.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ Aspire provides first-class APIs for defining Ingress and Gateway API resources
and is the recommended path for that scenario.
</Aside>

<Aside type="tip" title="Prefer Gateway API for new deployments">
The Kubernetes project recommends [Gateway
API](https://kubernetes.io/docs/concepts/services-networking/gateway/) as the
long-term successor to Ingress — the Ingress API is feature-frozen and all
new traffic-routing capabilities are landing in Gateway API instead. For new
Aspire deployments, prefer
[`AddGateway(...)`](/deployment/kubernetes-gateway-aks/) over
`AddIngress(...)` unless your cluster or controller doesn't yet support
Gateway API. See [Gateway API
concepts](https://gateway-api.sigs.k8s.io/concepts/api-overview/) for the
upstream design rationale.
</Aside>

## Ingress vs. Gateway API

Kubernetes offers two approaches for routing external traffic to your services:
Expand Down Expand Up @@ -51,6 +64,51 @@ When you use `AddIngress()` or `AddGateway()`, Aspire generates additional Kuber
- A `gateway.networking.k8s.io/v1 Gateway` resource with listeners (HTTP on port 80, HTTPS on port 443 if TLS is configured)
- One or more `HTTPRoute` resources attached to the Gateway, grouped by hostname

## Routing paths to services

Use `WithPath` on an Ingress (or `WithRoute` on a Gateway) to forward traffic for a URL path to one of your Aspire services. Each call adds a rule to the generated `Ingress` (or `HTTPRoute`) resource pointing at the named endpoint's backing Kubernetes service.

<Tabs syncKey='aspire-lang'>
Comment on lines +69 to +71
<TabItem id='csharp' label='C#'>
```csharp title="AppHost.cs"
var api = builder.AddProject<Projects.Api>("api");
var web = builder.AddProject<Projects.Web>("web");

var ingress = k8s.AddIngress("public")
.WithIngressClass("nginx")
Comment on lines +75 to +78
.WithHostname("app.example.com")
.WithTls();

// Route /api/* to the API service and everything else to the web frontend.
ingress.WithPath("/api", api.GetEndpoint("http"));
ingress.WithPath("/", web.GetEndpoint("http"));
```
</TabItem>
<TabItem id='typescript' label='TypeScript'>
```typescript title="apphost.mts"
const api = await builder.addProject('api');
const web = await builder.addProject('web');

const ingress = await k8s.addIngress('public');
await ingress.withIngressClass('nginx');
await ingress.withHostname('app.example.com');
await ingress.withTls();

// Route /api/* to the API service and everything else to the web frontend.
await ingress.withPath('/api', api.getEndpoint('http'));
await ingress.withPath('/', web.getEndpoint('http'));
```
</TabItem>
</Tabs>

`WithPath` defaults to a `Prefix` match — pass an `IngressPathType` argument to request `Exact` or `ImplementationSpecific` matching when your controller supports it. There's also a host-scoped overload (`WithPath("api.example.com", "/", endpoint)`) for routing different hostnames to different backends from the same Ingress. If you'd rather forward all unmatched traffic to a single service without enumerating paths, call `WithDefaultBackend(endpoint)` instead — the two APIs can be combined.

<Aside type="note">
Prior to Aspire 13.4, the Ingress path API was named `WithRoute`. The Gateway
API equivalent (`gateway.WithRoute(...)`) keeps the original name to match
the `HTTPRoute` resource it generates.
</Aside>

## TLS and certificates

When you configure TLS with `WithTls()`, Aspire handles the initial bootstrapping:
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/content/docs/whats-new/aspire-13-3.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ var ingress = k8s.AddIngress("public")
.WithTls("api-cert");

// Route requests at "/" to the project's HTTP endpoint.
ingress.WithRoute("/", api.GetEndpoint("http"));
ingress.WithPath("/", api.GetEndpoint("http"));
```
Comment on lines 392 to 396

</TabItem>
Expand Down
4 changes: 4 additions & 0 deletions src/frontend/src/content/docs/whats-new/aspire-13-4.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ For AKS, `AddAzureKubernetesEnvironment` now wires Azure Application Gateway for

Aspire 13.4 adds a Kubernetes manifest resource API for arbitrary manifests and an `AddHelmChart` API for installing external Helm charts as deployment pipeline steps. These APIs make it possible to include Kubernetes-native resources, ingress controllers, monitoring stacks, and other third-party charts alongside the resources generated from your Aspire application model.

### Ingress `WithRoute` renamed to `WithPath`

The Kubernetes `Ingress` routing API has been renamed from `WithRoute(...)` to `WithPath(...)` to better reflect the Kubernetes Ingress path-rule terminology and to disambiguate it from the Gateway API. Update existing AppHosts that call `ingress.WithRoute(...)` to call `ingress.WithPath(...)` instead. The Gateway API equivalent (`gateway.WithRoute(...)`) is unchanged.

### Consolidated Helm chart configuration

Helm chart name, version, description, release name, and namespace are now configured through the `WithHelm(...)` extension method. This replaces the previous parallel property-based configuration surface on `KubernetesEnvironmentResource` with one fluent entry point.
Expand Down
Loading