Make sure the namespace where you deploy your workloads has Istio sidecar injection enabled. Istio features (including mirroring) require injection to be active for the namespace.
- Primary goal: route 100% of client traffic to
v1while mirroring copies of those requests tov2. - Components used: Kubernetes Deployments, Service, Istio DestinationRule and VirtualService.
- Key Istio concepts: subsets (DestinationRule),
mirrorandmirrorPercentage(VirtualService).
1. Verify namespace injection
Confirm which namespaces have Istio sidecar injection enabled:istio-injection=enabled, enable injection before deploying the workloads.
2. Deploy two echo-server versions (v1 and v2)
Create a single YAML containing two Deployments:echo-server-v1 and echo-server-v2. Both share app: echo-server but use different version labels so Istio can create subsets that map to those versions.
app=echo-server and version):
3. Create a Service for the echo servers
Expose both versions through a ClusterIP Service that selects onapp: echo-server so client traffic can reach either subset depending on routing rules.
4. Tail logs for both versions
Open two terminals (or background one process) and stream logs from each pod to observe how mirrored requests appear in the mirror target. Terminal A (v1):5. Create a test pod to generate traffic
Run a small pod you can exec into for curl-based testing:test pod, call the echo service repeatedly and extract the responding pod hostname. The echo server returns JSON with a hostname field; use grep and sed to print it cleanly:
v2 while responses come from v1.
6. Define DestinationRule with subsets
Create an Istio DestinationRule that definesv1 and v2 subsets based on the version pod label. These subsets allow VirtualService routing rules to target specific versions.
7. Create a VirtualService that mirrors traffic
The VirtualService below routes 100% of production traffic to subsetv1 and mirrors each request to subset v2. mirrorPercentage.value accepts a float between 0.0 and 100.0 so you can partially mirror traffic if desired.
mirrorPercentage.value to a lower number (for example 10.0) to mirror only 10% of requests.
8. Test mirrored traffic
From thetest pod, run repeated curl commands and observe that client responses continue to come from v1 while v2 receives mirrored copies (visible in its logs).
Repeat the same curl command:
v2 logs — you should see similar GET entries for the mirrored requests even though the client never received responses from v2. This confirms mirroring is functioning: real traffic is served by v1, and duplicates are sent to v2 for analysis or testing.
Example request log from v1:
Quick reference table
Notes and references
- Mirroring does not change the client response; it only sends a copy of the request to the mirror target.
- Use
mirrorPercentageto limit the portion of requests that are mirrored (0.0–100.0). - Ensure labels in
DestinationRule.subsetsexactly match pod labels (version: v1/version: v2). - Mirroring is useful for testing new versions without impacting users: logs, tracing, or metrics from the mirror can validate behavior.
If you need the Gateway API or other CRDs present, ensure any required CRDs are installed before testing; for example, follow upstream installation instructions for the Gateway API when required by your environment.
- Istio Traffic Management — VirtualService & DestinationRule
- Istio: Traffic Mirroring Documentation
- Kubernetes Documentation
mirrorPercentage and subsets to experiment with partial mirroring and canary analysis in your cluster.