Traffic Mirroring
Traffic mirroring, also called shadowing, is a powerful concept that provides a risk-free method of testing your releases in the production environment without impacting your end users.
Instead of using traditional pre-production environments which used to be a replica of production, mirroring can provide synthetic traffic to mimic the live environment.
Traffic monitoring works in the following way:
- You deploy a new version of your component (v2)
- The existing version (v1) works loke before but sends an asynchronous copy to the new version
- The new version (v2) processes the incoming traffic but does not respond to the user (fire-and-forget)
- The Dev and Ops teams can monitor the new version in order to identify potential problems before starting the rollout
Let’s start the Lab.
Create a Virtual Service that sends all traffic to v1 of the
reviews
serviceapiVersion: networking.istio.io/v1alpha3kind: VirtualServicemetadata:name: reviewsspec:hosts:- reviewshttp:- route:Run the following:
kubectl apply -f ./istio/samples/bookinfo/networking/virtual-service-all-v1.yaml> virtualservice.networking.istio.io/reviews configuredCreate a Virtual Service that sends all traffic to v1 and mirrors it to v2 of the
reviews
serviceapiVersion: networking.istio.io/v1alpha3kind: VirtualServicemetadata:name: reviewsspec:hosts:- reviewshttp:- route:Run the following:
kubectl apply -f ./istio/samples/bookinfo/networking/virtual-service-mirror-v1-v2.yaml> virtualservice.networking.istio.io/reviews configuredAfter a short while you should see traffic starting to flow from
reviews
(v2) toratings
, becausereviews
(v2) is receiving the mirrored traffic.
