Skip to main content
This lesson explains the HTTPRoute resource from the Kubernetes Gateway API and how it declares how your application is exposed. Typically you create three resources in this order before an HTTPRoute becomes active:
  1. A GatewayClass (defines controller behavior).
  2. A Gateway (instantiated per cluster/namespace).
  3. An HTTPRoute that attaches to the Gateway and defines hostnames, matches, and backends.
An HTTPRoute:
  • 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.
Common HTTPRoute manifest
Quick reference: main spec sections How matches.path behaves
  • PathPrefix — routes when the request path starts with the prefix. Example: /tea matches /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).
Match types table Best practices and tips
  • Use PathPrefix for grouping related endpoints (APIs, microservice endpoints). Use Exact for 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 namespace in parentRefs when 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.
Further reading We’ll cover advanced traffic management — such as regex matches, weighted backends, and header/query-param based routing — in a later lesson. That’s it for this lesson. I hope you enjoyed it.

Watch Video