Gateway API

A team attaches its HTTPRoute to a shared Gateway in another namespace and points it at a Service in a third. Yet the route fails or answers HTTP 500. Whose permissions does it need, and where is each written?

Play the animation 6 steps, animated, plays on a computer or a tablet

Gateway API, Kubernetes diagram

Gateway API, step by step

  1. Gateway API is an add-on whose kinds are custom resources. The cluster-scoped GatewayClass example names the controller that implements it in controllerName, and reads Accepted True once that controller takes it. Gateway shared-gw in namespace infra uses that class and declares an HTTPS listener on 443 with its certificate in certificateRefs. Its allowedRoutes keeps the default, from Same, and here the implementation runs a proxy for the Gateway.

    Play from step 1
  2. HTTPRoute web is created in namespace shop. Its parentRefs names shared-gw, and one rule sends shop.io/ to Service web in namespace web. The listener admits routes from infra alone, so the route reads Accepted False, reason NotAllowedByListeners.

    Play from step 2
  3. In Gateway shared-gw, allowedRoutes is edited to from Selector, matching namespace shop, and the route turns Accepted True. But its backendRef points into namespace web, where no ReferenceGrant allows it, so ResolvedRefs reads False, reason RefNotPermitted, and the implementation configures no backend for the rule.

    Play from step 3
  4. A client sends HTTPS for shop.io/ to the Gateway address. The proxy terminates TLS and matches the accepted rule, but the only backendRef of that rule is invalid and the rule has no filters, so the request must get HTTP 500 instead of being forwarded.

    Play from step 4
  5. ReferenceGrant from-shop is created in namespace web, allowing HTTPRoutes in namespace shop to reference its Services. The backendRef resolves and ResolvedRefs turns True, so the rule now has a backend, Service web, which selects Pod web.

    Play from step 5
  6. The same request now matches Host and path against a configuration built from the Gateway and the HTTPRoute, and the rule has a backend. An implementation may send it to the Service IP or to the backing EndpointSlices, and here the proxy forwards it straight to Pod web at 10.244.1.5.

    Play from step 6

Sources