# TLS on a Gateway with cert-manager

> Annotate the Gateway and cert-manager issues a certificate for every HTTPS listener that names a hostname. The catch is where the Secret lives: always the Gateway's namespace, which decides who owns your certificates.

- Canonical: https://www.alpacamango.com/docs/cert-manager-gateway-api-tls
- Author: Space Dog Vin
- Published: 2026-11-23 · Updated: 2026-11-20
- Topics: Kubernetes, Gateway API

**Annotate the Gateway with an issuer and cert-manager does the rest: it reads every HTTPS listener, requests a certificate for its hostname and writes the Secret the listener points at. The decision is where that Secret lives. cert-manager only ever writes it into the Gateway's own namespace, so either the platform team owns every certificate, or you need ListenerSets, or you manage the certificate yourself and grant the Gateway access to it.**

## How a certificate attaches to a listener

With Ingress, TLS was a block inside each team's Ingress. With the Gateway API it moves to the listener, which is the platform's object. A listener on port 443 with `protocol: HTTPS` and `tls.mode: Terminate` names one or more Secrets in `certificateRefs`; the Gateway presents them, and HTTPRoutes in other namespaces attach to it without ever seeing a key.

cert-manager hooks in at exactly that point. Put `cert-manager.io/cluster-issuer` (or `cert-manager.io/issuer` for one in the same namespace) on the Gateway, and for each listener it can use it creates a Certificate named after the Secret, with the listener's hostname as the DNS name:

```yaml
metadata:
  name: edge
  namespace: gateway-system
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt
spec:
  listeners:
  - name: shop-https
    hostname: shop.example.com
    port: 443
    protocol: HTTPS
    tls:
      mode: Terminate
      certificateRefs:
      - name: shop-example-com-tls
```

Listeners sharing a Secret name become one Certificate with several names. Renewal is the usual cert-manager loop: the Secret is rewritten in place and the listener keeps pointing at the same name.

## Turning it on

Since cert-manager 1.15 this is not a feature gate, but it is still off by default: set the Helm value `config.gatewayAPI.enabled` to true. cert-manager also checks for the Gateway API CRDs when it starts. Install the CRDs after cert-manager and it carries on as though they were not there. Restart the cert-manager Deployment after installing the CRDs and the mystery goes away.

## Listeners cert-manager skips, quietly

cert-manager passes over any listener it cannot turn into a Certificate, and the Gateway itself will look healthy. The reasons you are likely to hit:

- **No hostname.** A catch-all HTTPS listener gets nothing, because there is no name to put on the certificate.
- **Passthrough.** The Gateway never sees the TLS, so there is nothing to terminate; the backend owns its own certificate.
- **A Secret in another namespace.** See below.
- **A reference that is not a plain Secret**: another `kind` or `group`, or an empty name.

When HTTPS fails on a new Gateway, run `kubectl get certificate` in the Gateway's namespace first. If there is no Certificate for your listener, one of those is almost always why.

## The namespace and ReferenceGrant trap

The Gateway API lets a listener reference a Secret in another namespace, provided a ReferenceGrant in the Secret's namespace allows Gateways from the first one to read Secrets. People reasonably assume cert-manager will issue into that namespace. It will not: cross-namespace `certificateRefs` are one of the listeners it skips. So there are two separate paths, and mixing them is how certificates fail to appear:

1. **Annotation path.** Secrets live beside the Gateway. Simple, and every private key sits in one namespace you can lock down to the platform team. App teams cannot add a hostname without editing the Gateway.
2. **Self-managed path.** An app team creates its own Certificate resource in its own namespace and adds a ReferenceGrant there; the platform adds a listener that points across. More objects, but each key stays with the team that owns the service.

The third option is newer. A ListenerSet lets a team declare listeners for a shared Gateway from its own namespace, and cert-manager honours its annotations, so the Secret is created next to the team's routes. It needs Gateway API 1.5 or later, and in cert-manager it is still alpha in 1.21 (it arrived in 1.20), behind an extra Helm value and the `ListenerSets` feature gate, so treat it as the direction of travel rather than the default.

## HTTP-01 through the Gateway

An ACME issuer with the `gatewayHTTPRoute` solver answers the challenge by creating a temporary HTTPRoute, which needs a listener on port 80 that accepts routes from the namespace the Certificate is in. If your port-80 listener only allows routes from its own namespace and the Certificate lives elsewhere, the challenge route is never attached and the order hangs. A catch-all redirect to HTTPS on port 80 is fine: the challenge route names the exact hostname and the exact token path, and the Gateway API ranks both above a catch-all prefix. Wildcard hostnames need DNS-01 instead, because HTTP-01 cannot prove control of a wildcard.

For the routing model behind all this, read [the Gateway API for people who know Ingress](/docs/gateway-api-for-ingress-users). If you are here because ingress-nginx is going, [its retirement options](/docs/ingress-nginx-retirement-options) covers the move, and [canary releases with the Gateway API](/docs/gateway-api-canary-releases) is the next thing your HTTPS listener will carry.

## The diagram

A Gateway in the platform namespace with an issuer annotation, cert-manager turning its HTTPS listener into a Certificate and a Secret beside it, and an app team's HTTPRoute attaching from its own namespace. [Open it in archhy](https://archhy.com/d/iXexruCyJBcc?utm_source=alpacamango) and press Make a copy to adapt it.
