A step by step demo showing how to configure Istio traffic mirroring to duplicate requests from a primary service to a mirror target for testing and telemetry.
Use this file to discover all available pages before exploring further.
This guide demonstrates Istio Service Mesh traffic mirroring. Traffic mirroring (also called shadowing) sends a duplicate of client requests to a mirror target while the primary target serves the actual response. It’s useful for testing, telemetry, and validating new revisions without impacting live traffic.Prerequisites:
An Istio-enabled cluster with sidecar injection enabled for the namespace you use.
kubectl configured to communicate with the cluster.
1) Confirm Istio sidecar injection is enabled for the namespace
Check the namespace labels to ensure istio-injection=enabled is present:
root@controlplane ~ ➜ kubectl get ns --show-labelsNAME STATUS AGE LABELSdefault Active 2m38s istio-injection=enabled,kubernetes.io/metadata.name=defaultistio-system Active 2m6s kubernetes.io/metadata.name=istio-systemkube-node-lease Active 2m38s kubernetes.io/metadata.name=kube-node-leasekube-public Active 2m38s kubernetes.io/metadata.name=kube-publickube-system Active 2m38s kubernetes.io/metadata.name=kube-systemroot@controlplane ~ ➜
We deploy two revisions of the same app. Note the shared app: echo-server label and distinct version labels — these version labels become DestinationRule subsets that Istio will use.
5) From a test pod, call the service to see which pod responds
If you don’t yet have a test pod, create one (for example, a busybox or alpine pod with curl). Exec into it and call the ClusterIP service. The echo-server JSON includes a HOSTNAME field — extract it to determine which pod served the response:
7) Create a VirtualService that routes to v1 and mirrors to v2
The VirtualService below routes 100% of client traffic to subset v1 and mirrors 100% of the requests to subset v2. Mirrored requests are sent in parallel to the mirror target; the mirror’s responses are discarded by the proxy.
Check the pod logs you left open — you’ll see matching request entries in both v1 and v2 logs. v1 serves the client; v2 receives mirrored traffic.
Traffic mirroring is a safe way to validate a new revision or collect telemetry. Mirrored requests are sent to the mirror target, but the proxy ignores mirror responses — client behavior is unaffected.
If examples reference Gateway API CRDs (common in some docs), ensure the Gateway CRDs are installed before applying manifests that rely on them. Example command to install a Gateway API release if CRDs are missing:
Selects pods by shared app label so traffic reaches both revisions
echo-server
DestinationRule
Defines v1 and v2 subsets that VirtualService references
dr.yaml
VirtualService
Routes client traffic to v1 and mirrors to v2
vs-mirror.yaml
This completes the mirroring demonstration. Try adjusting weights or mirror percentages to experiment with partial mirroring and collect telemetry from mirrored revisions without altering client-facing behavior.