Traffic Splitting, Header Routing & Mirroring with Gateway API
Split, match headers, and mirror traffic using Gateway API route capabilities.
In plain words
Gateway splitting is a toll gate sending a measured fraction to the new road and a silent copy camera to a test booth. The simple Kubernetes rule is: HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response.
Think of it like…
Gateway splitting is a toll gate sending a measured fraction to the new road and a silent copy camera to a test booth.
Where you’ve seen it
During a connectivity incident, the network owner runs kubectl get httproute checkout -o yaml; kubectl describe httproute checkout. Expected evidence: HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response. If the run instead shows this symptom, stop and restore the last known state: A mirrored target that becomes slow can still consume caller resources, and percentage weights are unreliable for tiny request samples or sticky sessions.
Words you’ll hear
- Traffic Split
- For this lesson, Traffic Split is the controlling idea: HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response.
- Header Match
- Header Match is the checkpoint; run
kubectl get httproute checkout -o yaml; kubectl describe httproute checkoutand inspect the owner chain. A mirrored target that becomes slow can still consume caller resources, and percentage weights are unreliable for tiny request samples or sticky sessions. - Mirroring
- Mirroring is the outcome to preserve; the cost is explicit: Header routing enables targeted canaries and mirroring removes response risk, but every backend needs capacity, authentication, and consistent normalization of the match.
- Verification evidence
- The evidence command is
kubectl get httproute checkout -o yaml; kubectl describe httproute checkout. It connects the declaration to this behavior: Split, match headers, and mirror traffic using Gateway API route capabilities.
Visual diagram
Theory & deep dive
How Traffic Split reaches the intended state
Split, match headers, and mirror traffic using Gateway API route capabilities. HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response.
The concrete checkpoint is kubectl get httproute checkout -o yaml; kubectl describe httproute checkout; compare the Traffic Split owner, Header Match state, and Mirroring outcome instead of treating YAML acceptance as proof.
Run kubectl get httproute checkout -o yaml; kubectl describe httproute checkout after the change and correlate the result with Events and the owning object. HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response.
Header Match: failure boundary and production cost
A mirrored target that becomes slow can still consume caller resources, and percentage weights are unreliable for tiny request samples or sticky sessions. The prerequisite contract is concrete: HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response.
Header routing enables targeted canaries and mirroring removes response risk, but every backend needs capacity, authentication, and consistent normalization of the match. A safe design limits blast radius, records the last good configuration, and uses kubectl get httproute checkout -o yaml; kubectl describe httproute checkout as a deterministic rollback checkpoint.
Capture the current state with kubectl get httproute checkout -o yaml; kubectl describe httproute checkout, then correct the controlling manifest rather than patching a child object; the relevant divergence signal is specific: A mirrored target that becomes slow can still consume caller resources, and percentage weights are unreliable for tiny request samples or sticky sessions.
How it works, step by step
Step 1 of 41. Define the reachability contract
Declare selectors, listeners, routes, or policy and keep endpoint readiness explicit: HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response.
- Goal
- Split, match headers, and mirror traffic using Gateway API route capabilities.
- Owner
- Traffic Split
When to use it & trade-offs
What it is
Split, match headers, and mirror traffic using Gateway API route capabilities. HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response.
Why it matters: A mirrored target that becomes slow can still consume caller resources, and percentage weights are unreliable for tiny request samples or sticky sessions. The invariant at risk is specific: HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response. The quickest fact check before changing the design is kubectl get httproute checkout -o yaml; kubectl describe httproute checkout.
When to reach for it
- Use Traffic Split to enforce this invariant: HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response.
- Use Header Match evidence from
kubectl get httproute checkout -o yaml; kubectl describe httproute checkoutin reviews and incident timelines. Split, match headers, and mirror traffic using Gateway API route capabilities. - Choose the managed ingress or mesh route only when this cost is justified by governance or scale: Header routing enables targeted canaries and mirroring removes response risk, but every backend needs capacity, authentication, and consistent normalization of the match.
When to avoid or be careful
- Avoid assuming Traffic Split is complete after YAML submission; the required behavior is concrete: HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response.
- Avoid treating the next symptom as random; check the owner and state with
kubectl get httproute checkout -o yaml; kubectl describe httproute checkoutfirst: A mirrored target that becomes slow can still consume caller resources, and percentage weights are unreliable for tiny request samples or sticky sessions. - Avoid adopting a heavier platform wrapper before measuring its cost: Header routing enables targeted canaries and mirroring removes response risk, but every backend needs capacity, authentication, and consistent normalization of the match.
Native, manual, and managed paths for Traffic Split
kubectl get httproute checkout -o yaml; kubectl describe httproute checkout.Strengths: HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response.
Watch out: Header routing enables targeted canaries and mirroring removes response risk, but every backend needs capacity, authentication, and consistent normalization of the match. Recovery must also recognize this signal: A mirrored target that becomes slow can still consume caller resources, and percentage weights are unreliable for tiny request samples or sticky sessions.
kubectl get httproute checkout -o yaml; kubectl describe httproute checkout; the expected invariant is: HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response.Strengths: kubectl get httproute checkout -o yaml; kubectl describe httproute checkout gives immediate feedback without first building a platform layer.
Watch out: A manual change can hide drift, and unlike Traffic Split, it does not make this symptom self-documenting: A mirrored target that becomes slow can still consume caller resources, and percentage weights are unreliable for tiny request samples or sticky sessions.
kubectl get httproute checkout -o yaml; kubectl describe httproute checkout.Strengths: Platform controls can wrap this exact behavior in policy or dashboards: HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response.
Watch out: The added platform ownership buys value at this cost: Header routing enables targeted canaries and mirroring removes response risk, but every backend needs capacity, authentication, and consistent normalization of the match.
Interview signals & numbers to know
When this topic comes up
- Interview anchor: HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response.
- Trace Traffic Split to Mirroring through Header Match; the invariant is: HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response.
- Recognize the symptom: A mirrored target that becomes slow can still consume caller resources, and percentage weights are unreliable for tiny request samples or sticky sessions.
- Justify the cost: Header routing enables targeted canaries and mirroring removes response risk, but every backend needs capacity, authentication, and consistent normalization of the match.
- Verify with kubectl get httproute checkout -o yaml; kubectl describe httproute checkout instead of only inspecting YAML.
Benchmarks & rules of thumb
- 100
- is the relative total convention for explicit traffic weights
- 1%
- tiny traffic splits need enough samples before promotion
- 2
- different effects: route forwarding and non-blocking traffic mirroring
Common mistakes & follow-ups
Common interview mistakes
- Debugging only the child object misses the Traffic Split owner contract: HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response.
- Ignoring this telltale condition leads to unrelated changes: A mirrored target that becomes slow can still consume caller resources, and percentage weights are unreliable for tiny request samples or sticky sessions.
- Repeating
kubectl get httproute checkout -o yaml; kubectl describe httproute checkoutwithout an owner for remediation wastes retry cost. Header routing enables targeted canaries and mirroring removes response risk, but every backend needs capacity, authentication, and consistent normalization of the match.
Likely interviewer follow-ups
- How would API output and runtime evidence prove this behavior: HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response?
- Which owner object, logs, and Events would you inspect for this symptom-A mirrored target that becomes slow can still consume caller resources, and percentage weights are unreliable for tiny request samples or sticky sessions-?
- At what threshold would this cost become unacceptable: Header routing enables targeted canaries and mirroring removes response risk, but every backend needs capacity, authentication, and consistent normalization of the match?
kubectl get httproute checkout -o yaml; kubectl describe httproute checkout, name the failure, then justify the cost. Invariant: HTTPRoute matches requests by host, path, headers, or method and assigns backend weights, while RequestMirror can copy traffic without changing the primary response. Failure: A mirrored target that becomes slow can still consume caller resources, and percentage weights are unreliable for tiny request samples or sticky sessions. Cost: Header routing enables targeted canaries and mirroring removes response risk, but every backend needs capacity, authentication, and consistent normalization of the match.Knowledge check
Put it into practice
Practice related interview Q&A
Apply Traffic Splitting, Header Routing & Mirroring with Gateway API with generative AI interview Q&A and hands-on practice.