Subscribe

Exposing services with the Gateway API and cert-manager

ingress-nginx was retired in March 2026, so shorty gets HTTPS through the Gateway API instead: Envoy Gateway, a Gateway and HTTPRoutes, an HTTP to HTTPS redirect and a certificate from cert-manager, tested on kind with a local CA.

Exposing services with the Gateway API and cert-manager

For years the default answer to "how do I get HTTPS traffic into my cluster" was ingress-nginx plus cert-manager. That answer has actually changed. The community ingress-nginx controller was retired in March 2026: the repository is archived and there are no more releases or security fixes. The Kubernetes project points people to the Gateway API, which is the successor to the Ingress resource.

In this blog we will expose shorty through the Gateway API with Envoy Gateway as the controller, redirect HTTP to HTTPS, and get the certificate from cert-manager. Level is intermediate. You should have the kind cluster from the first Kubernetes post with shorty running (configured with probes so the Gateway only sends traffic to ready pods), plus Helm installed. If something below gets stuck, the debugging runbook is where I'd start.

One honest limitation up front. Let's Encrypt has to reach your domain over the internet to issue a certificate, and a cluster on a laptop can't be reached. So for the run I used cert-manager with a local CA issuer. The Let's Encrypt part at the end is the config I'd use on a real cluster, checked against the CRDs with a server-side dry run, but not issued.

Versions: kind v0.33.0 with Kubernetes v1.37.0, Envoy Gateway v1.10.0 (which ships the Gateway API v1.6.1 CRDs, while v1.7.0 is the latest Gateway API release), cert-manager v1.21.3, Helm v4.3.

Gateway API in two minutes

Ingress was one resource that tried to do everything, and every controller added its own annotations on top. The Gateway API splits it by who owns what:

  • GatewayClass: which controller implements it. Set up once per cluster.
  • Gateway: the actual listeners (ports, hostnames, TLS). Usually owned by whoever runs the platform.
  • HTTPRoute: which hostnames and paths go to which Service. Owned by the app team, attached to a Gateway.

Things that needed annotations on Ingress, like redirects, header changes or traffic splits, are normal fields now. If you have Ingress objects with nginx annotations today, the ingress2gateway tool from SIG Network converts many of them.

Installing Envoy Gateway

The Gateway API is only the spec, you need a controller. I picked Envoy Gateway. Cilium, Istio, Traefik, NGINX Gateway Fabric and the cloud load balancer controllers implement it too.

helm install eg oci://docker.io/envoyproxy/gateway-helm --version v1.10.0 \
  -n envoy-gateway-system --create-namespace
kubectl wait --timeout=5m -n envoy-gateway-system deployment/envoy-gateway --for=condition=Available

The chart installs the Gateway API CRDs as well. To check which version you got:

kubectl get crd gateways.gateway.networking.k8s.io \
  -o jsonpath='{.metadata.annotations.gateway\.networking\.k8s\.io/bundle-version}'

That printed v1.6.1. If you install the CRDs yourself, match them to what the controller supports, not just the newest release.

Installing cert-manager

cert-manager's Gateway support has to be switched on in its controller config. With the Helm chart that's a values file:

crds:
  enabled: true
config:
  apiVersion: controller.config.cert-manager.io/v1alpha1
  kind: ControllerConfiguration
  gatewayAPI:
    enabled: true
helm install cert-manager oci://quay.io/jetstack/charts/cert-manager --version v1.21.3 \
  -n cert-manager --create-namespace -f cert-manager-values.yaml
kubectl -n cert-manager logs deploy/cert-manager | grep -i gateway

The log line to look for is enabling the sig-network Gateway API certificate-shim and HTTP-01 solver. If it's missing, cert-manager will silently ignore your Gateway annotations. Install the Gateway API CRDs (Envoy Gateway in our case) before cert-manager, because it checks for them when it starts.

A local CA instead of Let's Encrypt

For the local run: a self-signed issuer makes a root CA certificate, and a CA issuer signs everything else with it. That gives a proper chain that curl can check with --cacert.

apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: selfsigned
spec:
  selfSigned: {}
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: local-root-ca
  namespace: cert-manager
spec:
  isCA: true
  commonName: local-root-ca
  secretName: local-root-ca
  duration: 8760h
  privateKey:
    algorithm: ECDSA
    size: 256
  issuerRef:
    name: selfsigned
    kind: ClusterIssuer
---
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: local-ca
spec:
  ca:
    secretName: local-root-ca

The CA's Secret lives in the cert-manager namespace on purpose. A ClusterIssuer reads its Secrets from the namespace cert-manager runs in.

kubectl apply -f issuers.yaml
kubectl get clusterissuer

The Gateway

apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
  name: eg
spec:
  controllerName: gateway.envoyproxy.io/gatewayclass-controller
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: web
  namespace: default
  annotations:
    cert-manager.io/cluster-issuer: local-ca
spec:
  gatewayClassName: eg
  listeners:
    - name: http
      protocol: HTTP
      port: 80
      hostname: sho.example.com
    - name: https
      protocol: HTTPS
      port: 443
      hostname: sho.example.com
      tls:
        mode: Terminate
        certificateRefs:
          - name: sho-example-com-tls

The annotation is the whole cert-manager integration. cert-manager sees an HTTPS listener with a hostname and a certificateRefs Secret name, and creates a Certificate for that hostname into that Secret. You don't write a Certificate yourself.

The routes

Two HTTPRoutes. One on the http listener that only redirects, and one on https that sends everything to the shorty Service:

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: shorty-redirect
spec:
  parentRefs:
    - name: web
      sectionName: http
  hostnames:
    - sho.example.com
  rules:
    - filters:
        - type: RequestRedirect
          requestRedirect:
            scheme: https
            port: 443
            statusCode: 301
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: shorty
spec:
  parentRefs:
    - name: web
      sectionName: https
  hostnames:
    - sho.example.com
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /
      backendRefs:
        - name: shorty
          port: 80

sectionName attaches a route to one listener. Without it the redirect route attaches to both listeners, and on HTTPS it would compete with the shorty route for the same host and path.

kubectl apply -f gateway.yaml -f routes.yaml
kubectl wait gateway/web --for=condition=Programmed --timeout=180s

That wait timed out. Here is why:

kubectl get gateway web -o jsonpath='{range .status.conditions[*]}{.type}={.status} {.reason}{"\n"}{end}'
Accepted=True Accepted
Programmed=False AddressNotAssigned

Basically, Envoy Gateway creates a Service of type LoadBalancer for each Gateway, and kind has no load balancer, so the Service sat at EXTERNAL-IP <pending> and the Gateway had no address. The listeners themselves were fine (each listener showed Programmed=True), and the Certificate was already issued:

NAME                  READY   SECRET                AGE
sho-example-com-tls   True    sho-example-com-tls   3m5s

On a cloud cluster the address comes from the cloud's load balancer. On kind you can run the cloud-provider-kind helper to get one, but I just used port-forward to the Envoy Service only.

Testing it

SVC=$(kubectl -n envoy-gateway-system get svc \
  -l gateway.envoyproxy.io/owning-gateway-name=web -o jsonpath='{.items[0].metadata.name}')
kubectl -n envoy-gateway-system port-forward svc/$SVC 8080:80 8443:443 &
kubectl -n cert-manager get secret local-root-ca -o jsonpath='{.data.ca\.crt}' | base64 -d > ca.crt

The redirect:

curl -sI -H 'Host: sho.example.com' http://127.0.0.1:8080/kind | grep -i location
location: https://sho.example.com/kind

My first try used curl --resolve sho.example.com:8080:127.0.0.1, which sends Host: sho.example.com:8080, and the Location kept :8080 even with port: 443 in the filter. With a plain Host header it was right. Behind a real load balancer on 80 and 443 you won't see this, but it confused me quite a bit.

HTTPS, checked against our CA:

curl -si --cacert ca.crt --resolve sho.example.com:8443:127.0.0.1 https://sho.example.com:8443/kind | head -4
HTTP/2 302
cache-control: private, max-age=0
content-type: text/html; charset=utf-8
location: https://kind.sigs.k8s.io/

Envoy speaks HTTP/2 to the client while shorty only sees plain HTTP/1.1 inside the cluster. Without --cacert, curl failed with SSL certificate problem: unable to get local issuer certificate, which is what you want. A hostname with no listener, like other.example.com, failed the TLS handshake with SSL_ERROR_SYSCALL. And the certificate cert-manager made:

kubectl get secret sho-example-com-tls -o jsonpath='{.data.tls\.crt}' | base64 -d \
  | openssl x509 -noout -issuer -dates -ext subjectAltName
issuer=CN=local-root-ca
notBefore=Nov 19 07:47:06 2026 GMT
notAfter=Feb 17 07:47:06 2027 GMT
X509v3 Subject Alternative Name: critical
    DNS:sho.example.com

90 days, the cert-manager default, renewed automatically before it runs out. I also set BASE_URL in shorty's ConfigMap to https://sho.example.com so the short_url in its responses matches.

Switching to Let's Encrypt

On a real cluster with DNS for your hostname pointing at the Gateway's address, you add an ACME ClusterIssuer and change the annotation. I did not run this one, Let's Encrypt can't reach a kind cluster. I only checked it with kubectl apply --dry-run=server, which validates it against the installed cert-manager CRDs:

apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: letsencrypt-staging
spec:
  acme:
    server: https://acme-staging-v02.api.letsencrypt.org/directory
    email: you@example.com
    privateKeySecretRef:
      name: letsencrypt-staging-account
    solvers:
      - http01:
          gatewayHTTPRoute:
            parentRefs:
              - name: web
                namespace: default
                kind: Gateway
                sectionName: http

For production, copy it with the name letsencrypt and the server https://acme-v02.api.letsencrypt.org/directory. Then the Gateway annotation becomes cert-manager.io/cluster-issuer: letsencrypt-staging first, and letsencrypt once staging works. Staging has much higher rate limits so you can get things wrong a few times without being locked out.

With the HTTP-01 solver, cert-manager creates a temporary HTTPRoute on the http listener for /.well-known/acme-challenge/<token>. Will our catch-all redirect swallow it? No. Gateway API picks the most specific path match, and the challenge path is far more specific than the redirect route's implicit / prefix. If you want wildcard certificates, you need a DNS-01 solver instead (Route 53, Cloudflare and so on).

The server running this blog gets its Let's Encrypt certificates through Caddy, the Caddy post has that setup. Same CA, the renewal is just done by cert-manager here. Let's Encrypt stopped sending expiry reminder emails in 2025, so on Kubernetes keep an eye on kubectl get certificate -A or cert-manager's metrics.

There we have it: no ingress-nginx anywhere, and redirects and TLS are plain fields instead of annotations.