Kubernetes Lesson 30 of 70

Lesson 30 of 70 · 9 min read · Updated

Kubernetes Gateway API Fundamentals: GatewayClass, Gateway, Routes and Status Conditions

Ingress gave Kubernetes one small object for HTTP routing: a host, a path, a backend Service. Anything beyond that (rewrites, header matching, traffic splitting, timeouts) went into controller-specific annotations, so an Ingress written for one controller rarely worked on another. The Gateway API replaces that model with a set of typed, role-oriented resources that every implementation reads the same way.

This lesson covers the fundamentals without any controller installed: what each resource is for, who owns it, how routes attach to Gateways, and how to read status. The next two lessons install a real implementation (NGINX Gateway Fabric, then Traefik), and the rest of the series goes into routing, TLS, traffic splitting and multi-tenant setups.

The running example is PedalShare, a city bike-sharing platform with a stations API, a rides API, a pricing API and a gRPC fleet telemetry service.

Technical Requirements

  1. Docker, kind v0.33+ and kubectl 1.34+
  2. The sample repository: Fcakiroglu16/dotnetacademy, branch gateway-api-fundamentals

scripts/cluster-up.sh creates a kind cluster named gateway-lab (Kubernetes v1.36), builds the PedalShare images, loads them into the nodes and installs the Gateway API CRDs. The series uses Gateway API v1.6.3, the newest version supported by both NGINX Gateway Fabric 2.8 and Traefik 3.7 at the time of writing.

Why Ingress Was Not Enough

NeedIngressGateway API
Header, query or method matchingAnnotations, per controllermatches in HTTPRoute
Weighted traffic splitAnnotations or a separate CRDweight on backendRefs
Path rewrite, redirects, header changesAnnotationsBuilt-in filters
Protocols other than HTTPNot coveredGRPCRoute, TLSRoute, TCPRoute, UDPRoute
Shared entry point across teamsOne object mixes infra and app settingsGateway owned by ops, routes owned by teams
Reporting problemsMostly controller logsStandard status.conditions on every object

Ingress is not removed from Kubernetes, but it is frozen: no new features are added. The community Ingress NGINX controller reached end of life in March 2026, which pushed many clusters to move to Gateway API.

Core Concepts

The three roles

The API splits ownership between three personas. Each one edits only its own resources.

  1. Infrastructure provider: installs an implementation and publishes a GatewayClass.
  2. Cluster operator: creates Gateway objects, picks ports, hostnames and TLS certificates, and decides which namespaces may attach routes.
  3. Application developer: writes HTTPRoute or GRPCRoute objects in their own namespace, pointing at their own Services.

RBAC follows the same split: developers can get write access to routes without being able to open a new port on the edge proxy.

GatewayClass

A cluster-scoped object that names a controller through spec.controllerName. It works like StorageClass: it describes a kind of Gateway, not a running proxy. Installing NGINX Gateway Fabric creates a class called nginx; installing Traefik creates traefik.

Gateway

A namespaced request for an entry point. It references a GatewayClass and lists listeners. Each listener has a name, a protocol (HTTP, HTTPS, TLS, TCP, UDP), a port, an optional hostname, TLS settings and allowedRoutes. When a controller accepts the Gateway, it starts (or configures) a data plane and writes the address into status.addresses.

Routes

Routes carry the actual routing rules. Each rule has matches, optional filters and backendRefs.

ResourceMatches onTypical use
HTTPRouteHost, path, headers, query, methodREST APIs, web apps
GRPCRouteHost, gRPC service and method, headersgRPC services
TLSRouteSNI hostname (TLS passthrough)Backends that terminate TLS themselves
TCPRoute / UDPRouteListener port onlyDatabases, DNS, game servers

Attachment: parentRefs and allowedRoutes

A route asks to join a Gateway through spec.parentRefs, optionally naming one listener with sectionName. The Gateway decides whether to accept it with allowedRoutes:

  1. from: Same: routes only from the Gateway's namespace (the default)
  2. from: Selector: routes from namespaces that match a label selector
  3. from: All: routes from any namespace

Both sides must agree. A route that points at a Gateway that does not allow it is rejected with NotAllowedByListeners.

ReferenceGrant and other resources

  1. ReferenceGrant: lets an object in one namespace reference an object in another one, for example a route in pedalshare-rides sending traffic to a Service in pedalshare-pricing. Without it, cross-namespace backendRefs fail with RefNotPermitted.
  2. ListenerSet: lets teams add listeners to a shared Gateway from their own namespace (Standard since v1.5).
  3. BackendTLSPolicy: tells the Gateway to use TLS when it connects to a backend.

Release channels

Each release ships two bundles. Standard contains only GA resources and fields, which are covered by compatibility guarantees. Experimental adds alpha resources and fields that may still change. Install only one channel per cluster, and use Standard unless you need a specific experimental feature.

Status conditions

Every controller reports the same conditions, so the same three commands tell you what went wrong on any implementation.

ObjectConditionMeaning when True
GatewayClassAcceptedA controller owns this class
GatewayAcceptedThe spec is valid and the controller will implement it
GatewayProgrammedThe data plane is configured and has an address
ListenerResolvedRefsCertificates and other references were found
Route (per parent)AcceptedThe parent Gateway took the route
Route (per parent)ResolvedRefsEvery backend and filter reference resolved

Hands-On: Kubernetes Commands

Create the lab cluster and install the CRDs:

git clone https://github.com/Fcakiroglu16/dotnetacademy.git
cd dotnetacademy
git switch gateway-api-fundamentals
scripts/cluster-up.sh

List what the CRDs added:

$ kubectl api-resources --api-group=gateway.networking.k8s.io
NAME SHORTNAMES APIVERSION NAMESPACED KIND
backendtlspolicies btlspolicy gateway.networking.k8s.io/v1 true BackendTLSPolicy
gatewayclasses gc gateway.networking.k8s.io/v1 false GatewayClass
gateways gtw gateway.networking.k8s.io/v1 true Gateway
grpcroutes gateway.networking.k8s.io/v1 true GRPCRoute
httproutes gateway.networking.k8s.io/v1 true HTTPRoute
listenersets lset gateway.networking.k8s.io/v1 true ListenerSet
referencegrants refgrant gateway.networking.k8s.io/v1 true ReferenceGrant
tcproutes gateway.networking.k8s.io/v1 true TCPRoute
tlsroutes gateway.networking.k8s.io/v1 true TLSRoute
udproutes gateway.networking.k8s.io/v1 true UDPRoute

Check which version and channel are installed. Controllers compare this annotation with the version they support:

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

kubectl explain documents every field, including its support level (Core, Extended or Implementation-specific):

kubectl explain gateway.spec.listeners.allowedRoutes.namespaces.from
kubectl explain httproute.spec.rules.matches

Step-by-Step Example

The goal is to model the PedalShare edge before choosing a controller. The manifests are in k8s/01-fundamentals.

Step 1: The GatewayClass

The class names a controller that does not exist yet, so we can see what the objects look like before anything implements them.

k8s/01-fundamentals/01-gatewayclass.yaml

# Infrastructure provider: names the controller that will implement Gateways of this class.
# No controller with this name runs in the cluster yet, on purpose.
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: pedalshare-edge
spec:
controllerName: example.com/not-installed-yet
description: Edge proxy for PedalShare public traffic

Step 2: The Gateway

The platform team owns pedalshare-infra. Its Gateway exposes one HTTP listener for *.pedalshare.local and accepts routes only from namespaces labelled pedalshare.io/edge-access=true.

k8s/01-fundamentals/02-gateway.yaml

# Cluster operator: one entry point, one HTTP listener, routes allowed only from labelled namespaces.
apiVersion: v1
kind: Namespace
metadata:
name: pedalshare-infra
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: public
namespace: pedalshare-infra
spec:
gatewayClassName: pedalshare-edge
listeners:
- name: http
protocol: HTTP
port: 80
hostname: "*.pedalshare.local"
allowedRoutes:
namespaces:
from: Selector
selector:
matchLabels:
pedalshare.io/edge-access: "true"

Step 3: A team's HTTPRoute

The stations team works in its own namespace, which carries the label. Its route attaches to the http listener of the shared Gateway and sends /stations to the stations-api Service.

k8s/01-fundamentals/03-httproute.yaml

# Application developer: attaches a route to the shared Gateway from the team's own namespace.
apiVersion: v1
kind: Namespace
metadata:
name: pedalshare-stations
labels:
pedalshare.io/edge-access: "true"
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: stations
namespace: pedalshare-stations
spec:
parentRefs:
- name: public
namespace: pedalshare-infra
sectionName: http
hostnames:
- stations.pedalshare.local
rules:
- matches:
- path:
type: PathPrefix
value: /stations
backendRefs:
- name: stations-api
port: 80

Step 4: Apply and read the status

$ kubectl apply -f k8s/01-fundamentals/01-gatewayclass.yaml \
-f k8s/01-fundamentals/02-gateway.yaml -f k8s/01-fundamentals/03-httproute.yaml
$ kubectl get gatewayclass,gateway -A
NAME CONTROLLER ACCEPTED
gatewayclass.gateway.networking.k8s.io/pedalshare-edge example.com/not-installed-yet Unknown

NAMESPACE NAME CLASS ADDRESS PROGRAMMED
pedalshare-infra gateway.gateway.networking.k8s.io/public pedalshare-edge Unknown

The conditions say exactly what is missing:

$ kubectl get gateway public -n pedalshare-infra \
-o jsonpath='{range .status.conditions[*]}{.type}={.status} {.reason}: {.message}{"\n"}{end}'
Accepted=Unknown Pending: Waiting for controller
Programmed=Unknown Pending: Waiting for controller

The HTTPRoute has no status at all. A route only gets a status.parents entry when a controller processes it. An empty status means that no controller has looked at the route, not that the route is broken.

Step 5: Validation happens in the API server

The CRDs include CEL validation rules, so some mistakes are rejected before any controller sees them. Here, a path without a leading slash is rejected:

$ kubectl apply --dry-run=server -f k8s/01-fundamentals/invalid/broken-route.yaml
The HTTPRoute "broken" is invalid: spec.rules[0].matches[0].path: Invalid value:
value must be an absolute path and start with '/' when type one of ['Exact', 'PathPrefix']

Other errors only show up in status, because only the controller can detect them: a missing Service, a missing TLS Secret, or a listener port the implementation cannot open.

Results

CheckResult
Gateway API v1.6.3 Standard CRDs installed10 resources, all served as v1
GatewayClass with no controllerAccepted=Unknown, reason Pending
Gateway on that classAccepted and Programmed are Unknown, no address
HTTPRoute attached to the GatewayNo status until a controller processes it
Relative path in PathPrefixRejected by the API server's CEL validation

Summary

  1. The Gateway API splits edge configuration into GatewayClass (provider), Gateway (operator) and routes (developers), and RBAC can follow that split.
  2. Routes attach through parentRefs, and Gateways decide what they accept through allowedRoutes. Cross-namespace backends need a ReferenceGrant.
  3. Install one release channel. Standard is the safe default, and the CRD annotations show which version is installed.
  4. Accepted, Programmed and ResolvedRefs mean the same thing on every implementation, so read status before reading logs.

In the next lesson, NGINX Gateway Fabric becomes the controller, and the same kind of Gateway gets a real NGINX data plane and an address.