KubernetesGatewayExtensions
Classstaticnet10.0
Provides extension methods for configuring Kubernetes Gateway API resources in the Aspire application model.
namespace Aspire.Hosting;
public static class KubernetesGatewayExtensions{ // ...}12 members
Methods12
Section titled MethodsIResourceBuilder<KubernetesGatewayResource> Adds a Kubernetes Gateway API Gateway resource to the application model as a child of the specified Kubernetes environment. The gateway generates a
gateway.networking.k8s.io/v1 Gateway resource and one or more HTTPRoute resources in the Helm chart output at publish time. WithGatewayAnnotation(IResourceBuilder<KubernetesGatewayResource>, string, string)extensionats exportIResourceBuilder<KubernetesGatewayResource> Adds a Kubernetes metadata annotation to the generated Gateway resource.
WithGatewayAnnotation(IResourceBuilder<KubernetesGatewayResource>, string, IResourceBuilder<ParameterResource>)extensionats exportIResourceBuilder<KubernetesGatewayResource> Adds a Kubernetes metadata annotation with a parameter value that will be resolved at deploy time.
IResourceBuilder<KubernetesGatewayResource> Sets the GatewayClass name that selects which controller implementation handles this gateway.
WithGatewayClass(IResourceBuilder<KubernetesGatewayResource>, IResourceBuilder<ParameterResource>)extensionats exportIResourceBuilder<KubernetesGatewayResource> Sets the GatewayClass name using a parameter that will be resolved at deploy time.
IResourceBuilder<KubernetesGatewayResource> Adds a hostname that this gateway's routes match. Multiple hostnames can be added by calling this method repeatedly. Routes without an explicit host apply to each configured hostname. Hostnames are used as
hostnames in generated HTTPRoute resources and as HTTPS listener hostnames when TLS is configured. WithHostname(IResourceBuilder<KubernetesGatewayResource>, IResourceBuilder<ParameterResource>)extensionats exportIResourceBuilder<KubernetesGatewayResource> Adds a hostname using a parameter that will be resolved at deploy time.
WithRoute(IResourceBuilder<KubernetesGatewayResource>, string, EndpointReference, GatewayPathMatchType)extensionats exportIResourceBuilder<KubernetesGatewayResource> Adds a path-based routing rule to the gateway. The rule matches each hostname configured with
KubernetesGatewayExtensions.WithHostname, or all hosts when no hostname is configured, and routes matching traffic to the endpoint's backing Kubernetes service. This generates an HTTPRoute resource attached to the Gateway. WithRoute(IResourceBuilder<KubernetesGatewayResource>, string, string, EndpointReference, GatewayPathMatchType)extensionats exportIResourceBuilder<KubernetesGatewayResource> Adds a host-and-path-based routing rule to the gateway. The rule matches traffic for the specified host and path, routing it to the given endpoint's backing Kubernetes service. This generates an
HTTPRoute resource with a hostnames filter. IResourceBuilder<KubernetesGatewayResource> Configures TLS termination on the gateway by adding an HTTPS listener that references a Kubernetes TLS secret. The Gateway terminates TLS and forwards plain HTTP to backends. This does not create a separate route — existing HTTPRoutes serve both HTTP and HTTPS. The TLS configuration applies to all hostnames configured via
KubernetesGatewayExtensions.WithHostname. WithTls(IResourceBuilder<KubernetesGatewayResource>, IResourceBuilder<ParameterResource>)extensionats exportIResourceBuilder<KubernetesGatewayResource> Configures TLS termination using a parameter for the secret name.
IResourceBuilder<KubernetesGatewayResource> Configures TLS termination with an auto-generated secret name derived from the gateway name.