The Gateway API

Intermediate · 16 min

Ingress's successor: GatewayClass, Gateway and Routes split by role, typed routing instead of annotations, cross-namespace rules, and release channels.

Before thisIngress and ingress controllers

KodeKloud · 16 min · from 0:30

The Gateway API

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by KodeKloudReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • The Gateway API splits one Ingress into resources per role: GatewayClass (the infrastructure provider), Gateway (the platform team's listeners, ports and TLS), and Routes (each app team's routing).
  • Routing features are typed fields, not annotations: header and query matches, weighted backends for canaries, redirects, rewrites, header filters, mirroring, timeouts and retries.
  • A Gateway decides which namespaces may attach Routes (allowedRoutes), and a ReferenceGrant must exist before a Route or Gateway may point at a Service or Secret in another namespace.
  • It isn't only HTTP: GRPCRoute, TLSRoute, TCPRoute and UDPRoute are all v1 in the v1.7 Standard channel, and the same resources configure service meshes through GAMMA.
  • The API ships as CRDs in Standard and Experimental channels, separately from Kubernetes releases. Like Ingress, it needs an implementation (Envoy Gateway, Cilium, Istio, NGINX Gateway Fabric, Traefik, cloud gateways).

Three people, one object

Picture who touches an Ingress in a real company. The cloud or platform vendor supplies the load balancer. The platform team decides which ports are open, which hostnames exist and which certificates are used. App teams decide that /api goes to their API. In the Ingress API all of that is in one object, and everything beyond hosts and paths goes through annotations. So either the app team can change listeners and TLS, or the platform team has to approve every path change. And none of it is portable between controllers.

The Gateway API started from those roles. It’s a family of resources, each owned by a different person, linked by references, with the common features made into typed fields. It went GA (v1.0) in October 2023 and it’s what the Kubernetes project now recommends for new work, especially since ingress-nginx’s retirement.

The resource model

GatewayClass, cluster-scoped, owned by the infrastructure provider. It names the controller that implements it, like an IngressClass:

apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata: {name: envoy}
spec:
  controllerName: gateway.envoyproxy.io/gatewayclass-controller

Gateway, owned by the platform team. It’s a request for an actual load balancer or proxy with listeners: ports, protocols, hostnames, TLS, and which namespaces may attach routes:

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata: {name: public, namespace: infra}
spec:
  gatewayClassName: envoy
  listeners:
  - name: https
    protocol: HTTPS
    port: 443
    hostname: "*.example.com"
    tls:
      mode: Terminate
      certificateRefs: [{name: wildcard-tls}]
    allowedRoutes:
      namespaces:
        from: Selector
        selector: {matchLabels: {gateway-access: "true"}}

HTTPRoute (and its siblings), owned by app teams in their own namespaces. A route attaches to a Gateway listener through parentRefs and says where its traffic goes:

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata: {name: shop, namespace: shop}
spec:
  parentRefs: [{name: public, namespace: infra, sectionName: https}]
  hostnames: [shop.example.com]
  rules:
  - matches:
    - path: {type: PathPrefix, value: /api}
      headers: [{name: x-canary, value: "true"}]
    backendRefs: [{name: api-v2, port: 80}]
  - matches:
    - path: {type: PathPrefix, value: /api}
    backendRefs:
    - {name: api, port: 80, weight: 90}
    - {name: api-v2, port: 80, weight: 10}
  - backendRefs: [{name: web, port: 80}]

Think of a shopping centre. The landlord owns the building (GatewayClass), centre management decides which entrances are open and which tenants may advertise at each one (Gateway), and each shop puts up its own signs (Routes).

What the typed fields buy

That one HTTPRoute does what took annotations or a second Ingress before: a header-based canary rule, a 90/10 weighted split, and a catch-all. Other built-in features include query-parameter and method matching, request and response header filters, redirects and URL rewrites, request mirroring, timeouts, and retries, which moved to the Standard channel in v1.7. Because they’re fields, the API server validates them. Making the canary’s path api without a slash was refused by the CRD’s own validation rules: value must be an absolute path and start with '/'. With Ingress, a typo in an annotation is usually silently ignored.

Implementations report results in status. A Gateway gets Accepted and Programmed conditions and its address, and a Route gets per-parent Accepted and ResolvedRefs. In the lab, with no controller running, both Gateway conditions sat at the CRD’s default reason, Pending, which is what you see when nothing implements the class.

Crossing namespaces safely

Two safety rules come from the role split. A listener’s allowedRoutes decides who may attach: the default is from: Same (only the Gateway’s namespace), and our Gateway allowed any namespace labelled gateway-access=true. And references across namespaces, such as a Route in shop pointing at a Service in payments, or a Gateway using a certificate Secret elsewhere, require a ReferenceGrant in the target namespace:

apiVersion: gateway.networking.k8s.io/v1
kind: ReferenceGrant
metadata: {name: shop-routes, namespace: payments}
spec:
  from: [{group: gateway.networking.k8s.io, kind: HTTPRoute, namespace: shop}]
  to: [{group: "", kind: Service}]

It works like a door that needs a key from both sides. Without the grant, the implementation marks the route RefNotPermitted.

Beyond HTTP, and channels

GRPCRoute routes gRPC by service and method. TLSRoute routes encrypted traffic by SNI without terminating it. TCPRoute and UDPRoute forward raw ports. In the v1.7 Standard install all of these, plus ListenerSet (listeners attached by other teams) and BackendTLSPolicy (TLS from the gateway to backends), are served at v1. The same resources also configure east-west traffic: under the GAMMA initiative, a mesh like Istio or Linkerd accepts HTTPRoutes whose parent is a Service, which the service mesh lesson returns to.

The API isn’t built into Kubernetes. It’s CRDs released on their own schedule, in a Standard channel (stable) and an Experimental channel (new fields and kinds, prefixed X in v1.7). The v1.7 install also adds a ValidatingAdmissionPolicy, safe-upgrades, which blocks accidental downgrades and mixing channels. When we applied the v1.6.3 CRDs over v1.7.0, it refused: Installing CRDs with version before v1.7.0 is prohibited by default. Usually your implementation’s install bundles a supported CRD version. Check its conformance report on the implementations page before choosing.

Coming from Ingress, ingress2gateway converts existing objects, including some ingress-nginx annotations, into Gateways and HTTPRoutes as a starting point.

About the video

The embed is a 16-minute clip, 0:30 to 16:47, of KodeKloud’s “Gateway API Explained: The Future of Kubernetes Networking”, April 2025. The clip’s chapters cover Ingress’s limitations, what the Gateway API is, GatewayClass, Gateway and Route objects, a comparison with Ingress, and implementations. The rest of the video is a documentation tour and a lab demo. It predates v1.5 to v1.7, so it shows TCP, UDP and TLS routes as experimental and doesn’t show retries in Standard, ListenerSet or the safe-upgrades policy. Judged from chapters and description, since transcripts can’t be fetched here, and from its “English (US) original” audio track. That DevOps Guy’s hands-on 40-minute video in deeper installs a controller and builds host, path, rewrite, header and HTTPS routing step by step.

What was run: against a local v1.37.3 API server with no Gateway controller, we installed the Gateway API v1.7.0 Standard CRDs, listed the served kinds, applied the GatewayClass, Gateway and HTTPRoute above, saw the CRD’s path validation error and the Pending conditions, and saw the safe-upgrades policy deny the v1.6.3 CRDs. No traffic flowed, and attachment and ReferenceGrant enforcement, which implementations do, are from the Gateway API docs and v1.7.0 release notes, checked 2026-11-28.

Where this fits

Gateways and Services decide where traffic goes. They don’t decide which Pods may talk to which. Next: network policies.

Check yourself

  1. 01An HTTPRoute in namespace shop names the Gateway public in infra as its parent, but the Route's status says NotAllowedByListeners. What do you check?

    The listener's allowedRoutes. By default a listener only accepts Routes from its own namespace (from Same). The platform team must allow shop, for example with from Selector and a label on the shop namespace, or from All.

  2. 02How do you send 10 percent of /api traffic to api-v2 with the Gateway API, and how did you do it with ingress-nginx?

    Two backendRefs in one HTTPRoute rule with weight 90 and weight 10, a typed field every conformant implementation supports. With ingress-nginx it took a second Ingress plus canary annotations specific to that controller.

  3. 03An HTTPRoute in shop sends traffic to a Service in the payments namespace and gets ResolvedRefs False with RefNotPermitted. Why?

    Cross-namespace references need consent from the target namespace. The payments team must create a ReferenceGrant allowing HTTPRoutes from shop to reference Services in payments. Without it, any team could route traffic into anyone's Service.

  4. 04Why does upgrading the Gateway API sometimes not involve upgrading Kubernetes at all?

    The Gateway API isn't built into the API server. It's a set of CRDs released on its own schedule (v1.7 in October 2026), installed by the cluster operator or the implementation, and versioned by channel.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark