# KubernetesGatewayResource

- Module: [Aspire.Hosting.Kubernetes](/reference/api/go/aspire.hosting.kubernetes.md)
- Version: `17.0.0`
- Kind: `handle`
- Source: [GitHub](https://github.com/microsoft/aspire/tree/2d325b13709752ba6d9a943635c5e2940a2530c0)

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.

## Definition

```go
type KubernetesGatewayResource interface {
    Resource
    ResourceWithParent
}
```

## Embeds

- `Resource`
- `ResourceWithParent`

## Methods

- [WithGatewayAnnotation](/reference/api/go/aspire.hosting.kubernetes/kubernetesgatewayresource/withgatewayannotation.md) -- `method` -- Adds a Kubernetes metadata annotation to the generated Gateway resource.
  ```go
  WithGatewayAnnotation(key string, value string) KubernetesGatewayResource
  ```
- [WithGatewayAnnotationParam](/reference/api/go/aspire.hosting.kubernetes/kubernetesgatewayresource/withgatewayannotationparam.md) -- `method` -- Adds a Kubernetes metadata annotation with a parameter value that will be resolved at deploy time.
  ```go
  WithGatewayAnnotationParam(key string, value ParameterResource) KubernetesGatewayResource
  ```
- [WithGatewayClass](/reference/api/go/aspire.hosting.kubernetes/kubernetesgatewayresource/withgatewayclass.md) -- `method` -- Sets the GatewayClass name that selects which controller implementation handles this gateway.
  ```go
  WithGatewayClass(className string) KubernetesGatewayResource
  ```
- [WithGatewayClassParam](/reference/api/go/aspire.hosting.kubernetes/kubernetesgatewayresource/withgatewayclassparam.md) -- `method` -- Sets the GatewayClass name using a parameter that will be resolved at deploy time.
  ```go
  WithGatewayClassParam(className ParameterResource) KubernetesGatewayResource
  ```
- [WithGatewayHostnameParam](/reference/api/go/aspire.hosting.kubernetes/kubernetesgatewayresource/withgatewayhostnameparam.md) -- `method` -- Adds a hostname using a parameter that will be resolved at deploy time.
  ```go
  WithGatewayHostnameParam(hostname ParameterResource) KubernetesGatewayResource
  ```
- [WithGatewayHostRoute](/reference/api/go/aspire.hosting.kubernetes/kubernetesgatewayresource/withgatewayhostroute.md) -- `method` -- 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.
  ```go
  WithGatewayHostRoute(host string, path string, endpoint EndpointReference, options ...*WithGatewayHostRouteOptions) KubernetesGatewayResource
  ```
- [WithGatewayPathRoute](/reference/api/go/aspire.hosting.kubernetes/kubernetesgatewayresource/withgatewaypathroute.md) -- `method` -- 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.
  ```go
  WithGatewayPathRoute(path string, endpoint EndpointReference, options ...*WithGatewayPathRouteOptions) KubernetesGatewayResource
  ```
- [WithGatewayTlsAuto](/reference/api/go/aspire.hosting.kubernetes/kubernetesgatewayresource/withgatewaytlsauto.md) -- `method` -- Configures TLS termination with an auto-generated secret name derived from the gateway name.
  ```go
  WithGatewayTlsAuto() KubernetesGatewayResource
  ```
- [WithGatewayTlsIssuer](/reference/api/go/aspire.hosting.kubernetes/kubernetesgatewayresource/withgatewaytlsissuer.md) -- `method` -- 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.
  ```go
  WithGatewayTlsIssuer(issuer CertManagerIssuerResource) KubernetesGatewayResource
  ```
- [WithGatewayTlsParam](/reference/api/go/aspire.hosting.kubernetes/kubernetesgatewayresource/withgatewaytlsparam.md) -- `method` -- Configures TLS termination using a parameter for the secret name.
  ```go
  WithGatewayTlsParam(secretName ParameterResource) KubernetesGatewayResource
  ```
- [WithHostname](/reference/api/go/aspire.hosting.kubernetes/kubernetesgatewayresource/withhostname.md) -- `method` -- 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.
  ```go
  WithHostname(hostname string) KubernetesGatewayResource
  ```
- [WithTls](/reference/api/go/aspire.hosting.kubernetes/kubernetesgatewayresource/withtls.md) -- `method` -- Configures TLS on a Kubernetes Gateway listener
  ```go
  WithTls(secretName string) KubernetesGatewayResource
  ```
