Skip to content
Docs Try Aspire
Docs Try

KubernetesGatewayResource Constructors

Class Constructors 1 member
Represents a Kubernetes Gateway API Gateway as a first-class resource in the Aspire application model. A Gateway defines listeners (ports, protocols, TLS) and HTTPRoutes attach to it for routing.
Constructor(string, KubernetesEnvironmentResource) Section titled Constructor(string, KubernetesEnvironmentResource)
Represents a Kubernetes Gateway API Gateway as a first-class resource in the Aspire application model. A Gateway defines listeners (ports, protocols, TLS) and HTTPRoutes attach to it for routing.
public class KubernetesGatewayResource
{
public KubernetesGatewayResource(
string name,
KubernetesEnvironmentResource environment)
{
// ...
}
}
name string The name of the gateway resource.
environment KubernetesEnvironmentResource The parent Kubernetes environment resource.

Create a gateway using KubernetesGatewayExtensions.AddGateway and configure routes using KubernetesGatewayExtensions.WithRoute.

At publish time, the gateway generates a gateway.networking.k8s.io/v1 Gateway resource with auto-inferred listeners and one or more HTTPRoute resources in the Helm chart output.

var k8s = builder.AddKubernetesEnvironment("k8s");
var gateway = k8s.AddGateway("public")
.WithGatewayClass("azure-alb-external");
var api = builder.AddProject<MyApi>("api");
gateway.WithRoute("/api", api.GetEndpoint("http"));