Aspirerelease/17.0
Watch Aspire live streamsDocsTry Aspire

KubernetesGatewayResource

Handle
📦 Aspire.Hosting.Kubernetes v13.6.5-preview.1.26559.7

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.

type KubernetesGatewayResource interface {
Resource
ResourceWithParent
}

Methods

Adds a Kubernetes metadata annotation to the generated Gateway resource.
WithGatewayAnnotation(
key string,
value string,
) KubernetesGatewayResource
keystringThe annotation key.
valuestringThe annotation value.
KubernetesGatewayResource

The resource builder.

Returns a handle; failures surface later via Err().

Adds a Kubernetes metadata annotation with a parameter value that will be resolved at deploy time.
WithGatewayAnnotationParam(
key string,
value ParameterResource,
) KubernetesGatewayResource
keystringThe annotation key.
valueParameterResourceA parameter resource builder for the annotation value.
KubernetesGatewayResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithGatewayClassbuilder
Sets the GatewayClass name that selects which controller implementation handles this gateway.
WithGatewayClass(className string) KubernetesGatewayResource
classNamestringThe GatewayClass name (e.g., "azure-alb-external", "istio").
KubernetesGatewayResource

The resource builder.

Returns a handle; failures surface later via Err().

Sets the GatewayClass name using a parameter that will be resolved at deploy time.
WithGatewayClassParam(className ParameterResource) KubernetesGatewayResource
classNameParameterResourceA parameter resource builder for the GatewayClass name.
KubernetesGatewayResource

The resource builder.

Returns a handle; failures surface later via Err().

Adds a hostname using a parameter that will be resolved at deploy time.
WithGatewayHostnameParam(hostname ParameterResource) KubernetesGatewayResource
hostnameParameterResourceA parameter resource builder for the hostname value.
KubernetesGatewayResource

The resource builder.

Returns a handle; failures surface later via Err().

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.
WithGatewayHostRoute(
host string,
path string,
endpoint EndpointReference,
options ...*WithGatewayHostRouteOptions,
) KubernetesGatewayResource
hoststringThe hostname to match (e.g., "api.example.com").
pathstringThe URL path to match. Must start with /.
endpointEndpointReferenceThe endpoint reference identifying the target service and port.
options...*WithGatewayHostRouteOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithGatewayHostRouteOptions argument.

PathType*GatewayPathMatchTypeThe path matching strategy. Defaults to PathPrefix.
KubernetesGatewayResource

The resource builder.

Returns a handle; failures surface later via Err().

Adds a path-based routing rule to the gateway. The rule matches each hostname configured with 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.
WithGatewayPathRoute(
path string,
endpoint EndpointReference,
options ...*WithGatewayPathRouteOptions,
) KubernetesGatewayResource
pathstringThe URL path to match (e.g., "/" or "/api"). Must start with /.
endpointEndpointReferenceThe endpoint reference identifying the target service and port.
options...*WithGatewayPathRouteOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithGatewayPathRouteOptions argument.

PathType*GatewayPathMatchTypeThe path matching strategy. Defaults to PathPrefix.
KubernetesGatewayResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithGatewayTlsAutobuilder
Configures TLS termination with an auto-generated secret name derived from the gateway name.
WithGatewayTlsAuto() KubernetesGatewayResource
KubernetesGatewayResource

The resource builder.

Returns a handle; failures surface later via Err().

Adds an HTTPS listener to the gateway and wires it to the supplied cert-manager ClusterIssuer. This adds the cert-manager.io/cluster-issuer annotation to the generated Gateway resource, causing cert-manager to provision and renew a certificate for each gateway listener hostname.
WithGatewayTlsIssuer(issuer CertManagerIssuerResource) KubernetesGatewayResource
issuerCertManagerIssuerResourceThe cert-manager ClusterIssuer to issue certificates from.
KubernetesGatewayResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithGatewayTlsParambuilder
Configures TLS termination using a parameter for the secret name.
WithGatewayTlsParam(secretName ParameterResource) KubernetesGatewayResource
secretNameParameterResourceA parameter resource builder for the secret name.
KubernetesGatewayResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithHostnamebuilder
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(hostname string) KubernetesGatewayResource
hostnamestringThe hostname to match (e.g., "api.example.com").
KubernetesGatewayResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithTlsbuilder
Configures TLS on a Kubernetes Gateway listener
WithTls(secretName string) KubernetesGatewayResource
secretNamestringThe name of the Kubernetes kubernetes.io/tls Secret.
KubernetesGatewayResource

The resource builder.

Returns a handle; failures surface later via Err().