Blue/green with Istio: subsets, weights and mirroring
One Service, two subsets, and a VirtualService that sends blue 100% until you swap the weights, applied in every client's sidecar. Mirroring lets green take real traffic before anyone depends on it. When a mesh is worth it.
ON THIS PAGE
With Istio, blue and green sit behind one ordinary Service and the routing decision moves into every client's sidecar: a DestinationRule names the two versions as subsets, and a VirtualService sends 100% to blue and 0% to green until you swap the numbers. Because every caller applies the rule, the release covers traffic between your own services, not just requests arriving at the edge. And Istio can do one thing the others cannot: mirror live traffic to green so you can watch it work before anyone depends on it.
Based on the article from Gazeek, our sister site for hands-on CKA and CKAD labs: Blue/green deployments with Istio. The DestinationRule, the VirtualService, the mirror and the test commands are there in full.
The moving parts#
- Sidecars on. Label the namespace for injection and restart the Deployments. No sidecar, no routing: a client outside the mesh ignores the rules and gets plain round-robin across both versions.
- One Service selecting
app: shop, so it covers both versions. - A DestinationRule naming subsets
blueandgreenby theversionlabel. - A VirtualService: a header rule for testing, then blue 100 and green 0.
The default route in the VirtualService names the two subsets and their weights; the release swaps them:
http:
- route:
- destination:
host: shop
subset: blue
weight: 100
- destination:
host: shop
subset: green
weight: 0Mirroring: the part worth having a mesh for#
Add a mirror to the route and every request to blue is copied to green; users still get blue's answer and green's is thrown away. You get green under real traffic, with real request shapes, at no risk to users. The one catch is the obvious one: a mirrored request is a real request, so anything that writes will write twice.
Mirroring is two more fields on that same route:
mirror:
host: shop
subset: green
mirrorPercentage:
value: 100.0Is it worth running a mesh for this?#
Not on its own. If you already run Istio, it is the natural place for blue/green and canaries, with per-version metrics thrown in. If you do not, the Gateway API does blue/green at the edge with a fraction of the moving parts. Note too that Istio is not on the CKA or CKAD: the exams ask for the same switch with a Service selector.
The series#
- Blue/green with a Service selector
- Blue/green with an Ingress
- Blue/green with the Gateway API
- Blue/green with Istio: this article
The diagram#
Drawn in archhy. Open it in archhy and press Make a copy to adapt it.
Go deeper#
Gazeek's full article has every manifest, the test commands (and why the sidecar's Server header means you check Pod logs instead), and the traps.
