Skip to content

Advertisement

DevOps Society

Kubernetes Gateway API Explained: Gateways, Routes and How It Replaces Ingress

Gateway API splits traffic management into GatewayClass, Gateway and Route objects owned by different people. What each one does, how a request flows through them, and how it compares with Ingress.

Published your local timeupdated

Kubernetes Gateway API Explained: Gateways, Routes and How It Replaces Ingress

If you learned Kubernetes networking through Ingress, the Gateway API can look like a lot of new objects to do the same job. It is not the same job, though. Ingress was designed when "route this hostname to that service" was most of what people needed. Gateway API is designed for clusters where a platform team runs the load balancers and dozens of app teams need to route their own traffic without stepping on each other.

This guide walks through the pieces using one example request.

The problem Ingress left behind

An Ingress object mixes two kinds of decisions. Which load balancer, which ports, which TLS settings: those are infrastructure choices. Which paths go to which service: those are app choices. Both live in one object, edited by whoever has access.

Anything beyond basic routing, like canary weights, header matching or timeouts, lives in annotations that only one controller understands. Moving from one controller to another means rewriting all of them. That became a real problem when the community ingress-nginx controller was retired earlier this year.

The three objects that matter

GatewayClass says which implementation handles gateways of this kind, a bit like a StorageClass for traffic. Your cloud provider or the controller you install usually creates it. You rarely touch it.

Gateway is an actual entry point: a load balancer with listeners on certain ports and hostnames, and TLS settings. The platform team owns these. A Gateway also says which namespaces are allowed to attach routes to it.

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

HTTPRoute is where app teams describe their traffic. It attaches to a Gateway by name and lists rules: match these hosts, paths or headers, send them to these backends.

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: checkout
  namespace: shop
spec:
  parentRefs:
  - name: public
    namespace: infra
  hostnames: ["shop.example.com"]
  rules:
  - matches:
    - path: { type: PathPrefix, value: /checkout }
    backendRefs:
    - name: checkout-v1
      port: 8080
      weight: 90
    - name: checkout-v2
      port: 8080
      weight: 10

That weight field is a canary release, written in the standard API. No annotations, and it works the same way on any conformant implementation.

Following one request

A user opens https://shop.example.com/checkout. The load balancer behind the public Gateway terminates TLS using the wildcard certificate. It looks at the routes attached to its HTTPS listener, finds the checkout HTTPRoute matching that host and path, and sends 90% of such requests to checkout-v1 and 10% to checkout-v2.

The platform team never had to edit anything for the shop team to set this up, and the shop team could not change the certificate or open a new port if they tried. That separation is the main reason to adopt Gateway API, more than any single feature.

Crossing namespaces safely

By default a route can only send traffic to services in its own namespace. If the shop team wants to route to a service owned by another team, the owning team has to allow it with a ReferenceGrant in their namespace. It is a small object, but it means nobody can quietly point traffic at someone else's backend.

Other route types

HTTPRoute is the one most people use. There is also GRPCRoute for gRPC services, and TLSRoute, TCPRoute and UDPRoute for traffic that is not HTTP. Support for the non-HTTP routes varies between implementations, so check the conformance report for whichever one you use.

Gateway API and Ingress side by side

IngressGateway API
Who edits whatOne object for everythingGateway for platform, routes for app teams
Canary weights, header matchingController-specific annotationsPart of the spec
ProtocolsHTTP and HTTPSHTTP, gRPC, TLS, TCP, UDP
StatusStable but frozenWhere new features land

Getting started

Pick an implementation first. Managed options exist on the big clouds, including EKS Auto Mode, which now supports Gateway API with no controller to install. In-cluster options include Envoy Gateway, Istio, Cilium (see our look at Cilium 1.20) and NGINX Gateway Fabric.

Then move one low-risk service. Ingress and Gateway API can run side by side, so you can shift DNS gradually and watch error rates. The ingress2gateway tool will translate many Ingress objects into routes for you, though anything that relied on unusual annotations needs a human to read it.

Quick answers

Is Gateway API replacing Ingress?

Ingress still works and is not being removed, but it is feature-frozen. New networking features in Kubernetes land in Gateway API, which is the recommended choice for new work.

What is the difference between a Gateway and an HTTPRoute?

A Gateway is the entry point, with its ports, hostnames and TLS settings, usually owned by a platform team. An HTTPRoute holds the routing rules for an application and attaches to a Gateway.

How do I do a canary release with Gateway API?

List two backends in an HTTPRoute rule and give each a weight, for example 90 and 10. The implementation splits traffic in that ratio without any vendor annotations.

Advertisement

Follow DevOps Society on LinkedIn

Practical infrastructure engineering in your feed.

Follow

Written by

DevOpsSociety Editorial Team

Editorial Team

The DevOpsSociety Editorial Team covers DevOps, cloud infrastructure, Kubernetes, AI infrastructure, platform engineering, cybersecurity, FinOps, and modern engineering practices. We publish practical insights, technical guides, architecture analysis, and research for engineers and technology leaders.

More from DevOpsSociety →
The Infrastructure Briefing

Get the infrastructure briefing.

Practical DevOps, cloud, AI infrastructure and engineering insights, delivered weekly. Read by engineers and engineering leaders.

No spam. Unsubscribe anytime.

Kubernetes Gateway API Explained: Gateways, Routes and How It Replaces Ingress, DevOps Society