Interview's MateKubernetes
Interview's Mate

Kubernetes

K8s · Workloads · GitOps · Cloud

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Kubernetes topics
Lesson 54/ 160
03. Kubernetes Networking & Traffic Management

Traffic Splitting, Header Routing & Mirroring with Gateway API

Split, match headers, and mirror traffic using Gateway API route capabilities.

AdvancedTraffic Split · Header Match · Mirroring3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

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 checkout and 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

Loading interactive 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.

Verify Header Match, not only object creation

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.

Key takeaway: Traffic Split is implemented only when this invariant remains observable: 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.

Recover from Header Match drift

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.

Key takeaway: Accept the trade-off consciously: Header routing enables targeted canaries and mirroring removes response risk, but every backend needs capacity, authentication, and consistent normalization of the match.

How it works, step by step

Step 1 of 4
Traffic author

1. 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.

Traffic Split contract → owned state
Key numbers at this step
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 checkout in 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 checkout first: 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

Built-in API path
Best for: Split, match headers, and mirror traffic using Gateway API route capabilities. A concrete incident check is 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.

Datapath-specific extension
Best for: Quickly testing the Header Match assumption with 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.

Managed ingress or mesh
Best for: Teams that need Mirroring integrated with guardrails; the evidence path is 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 checkout without 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?
Interview tip: Interview sequence: state the invariant, run 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

Loading quiz

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.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Kubernetes Gateway API (Next-Gen Replacement for Ingress: GatewayClass, Gateway, HTTPRoute)
Next topic
NetworkPolicies: Layer 3/4 Micro-Segmentation (Ingress & Egress Rules)