- A GatewayClass (defines controller behavior).
- A Gateway (instantiated per cluster/namespace).
- An HTTPRoute that attaches to the Gateway and defines hostnames, matches, and backends.
- References the Gateway (and optionally a specific listener) that should parent the route.
- Declares which hostnames (FQDNs) it should serve.
- Defines one or more rules that match incoming requests and forward them to Kubernetes Services via
backendRefs.
spec sections
How
matches.path behaves
PathPrefix— routes when the request path starts with the prefix. Example:/teamatches/tea,/tea/green,/tea/info.Exact— routes only when the path equals the provided value exactly (no trailing segments).RegularExpression— use a regex for complex matching and capture groups.queryParams— match on specific query parameter names/values (useful for canary or blue/green routing).
Best practices and tips
- Use
PathPrefixfor grouping related endpoints (APIs, microservice endpoints). UseExactfor endpoint-specific rules where trailing segments would break behavior. - Combine path matches with header or query-parameter matches for advanced traffic shaping (covered in a later lesson).
- Prefer explicit
namespaceinparentRefswhen the Gateway is not in the same namespace as the HTTPRoute to avoid lookup failures.
When the Gateway and the HTTPRoute live in different namespaces, be sure to set the
namespace field inside the parentRefs item so the controller can resolve the parent Gateway.- Gateway API docs: https://gateway-api.sigs.k8s.io/
- Kubernetes networking overview: https://kubernetes.io/docs/concepts/services-networking/