CKAD · 20 November 2026 · 5 min read

Blue/green deployments with Istio

One Service, two subsets, and a VirtualService that sends blue 100% and green 0%. Test green with a header or mirror live traffic to it, then swap the weights. With YAML and the traps that catch people out.

With Istio, blue and green sit behind one ordinary Service, and Istio decides which Pods get each request: a DestinationRule names the two versions as subsets by their version label, and a VirtualService sends 100% of traffic to the blue subset and 0% to green. A header rule lets you test green, and mirroring copies live requests to green without users seeing its answers. To release, swap the weights; to roll back, swap them again. Because the switch happens in each client's sidecar, it applies to traffic between services inside the mesh, not only at the edge.

TL;DR

  • Sidecars on: kubectl label namespace shop istio-injection=enabled, then restart the Deployments.
  • One Service shop selecting app: shop (both versions).
  • DestinationRule: subsets blue and green by the version label.
  • VirtualService: header x-version: green goes to green; everyone else by weight, blue 100, green 0.
  • Optional: mirror live traffic to green to test it with real requests.
  • Switch: weights 0 and 100. Roll back: 100 and 0.
  • Exam: Istio is not on the CKA or the CKAD; the same switch is asked with a Service selector (part 1).

The whole pattern in one picture

Blue/green with Istio: client Envoy sidecars use VirtualService shop to send default traffic to blue Pod endpoints. DestinationRule shop defines the blue and green subsets from the version label; the header x-version: green and optional mirroring send test traffic to green.

Want to change it for your own setup? Open this diagram in archhy, our sister product for architecture diagrams, and press Make a copy in archhy: it opens as your own copy, ready to edit.

When Istio is worth it

Parts 1 to 3 switch traffic at one place: a Service, an Ingress or a Gateway. Istio moves the decision into every client, so the release covers calls between your own services too, and adds things the others do not: mirroring, retries, timeouts and per-version metrics. If you already run a mesh, it is the natural place for blue/green. If you do not, the Gateway API (part 3) does blue/green at the edge with far less to run.

Step 1: sidecars, Deployments and one Service

This assumes Istio in sidecar mode (in ambient mode, routing rules like these need a waypoint proxy). Turn injection on for the namespace and restart so the Pods get their sidecars:

Shell
kubectl label namespace shop istio-injection=enabledkubectl -n shop rollout restart deployment shop-blue shop-greenkubectl -n shop get pods   # READY should show 2/2

The Deployments are as before (version: blue on nginx:1.26, version: green on nginx:1.27), but there is only one Service, and it selects both:

YAML
apiVersion: v1kind: Servicemetadata:  name: shop  namespace: shopspec:  selector:    app: shop  ports:  - name: http    port: 80    targetPort: 80

Step 2: name the versions with a DestinationRule

YAML
apiVersion: networking.istio.io/v1kind: DestinationRulemetadata:  name: shop  namespace: shopspec:  host: shop  subsets:  - name: blue    labels:      version: blue  - name: green    labels:      version: green

Apply it before the VirtualService: a route that names a subset Istio does not know yet answers with errors.

Step 3: route by weight, and by header for testing

YAML
apiVersion: networking.istio.io/v1kind: VirtualServicemetadata:  name: shop  namespace: shopspec:  hosts:  - shop  http:  - match:    - headers:        x-version:          exact: green    route:    - destination:        host: shop        subset: green  - route:    - destination:        host: shop        subset: blue      weight: 100    - destination:        host: shop        subset: green      weight: 0

Rules are tried in order, so the header rule comes first. Test from a Pod inside the mesh (it gets a sidecar, so the rules apply), then check which version logged each request; the sidecar replaces nginx's Server header, so the logs are the reliable check:

Shell
kubectl -n shop run probe --image=curlimages/curl --restart=Never -- sleep 3600kubectl -n shop exec probe -c probe -- curl -s -o /dev/null -w '%{http_code}\n' http://shop/kubectl -n shop exec probe -c probe -- curl -s -o /dev/null -w '%{http_code}\n' -H 'x-version: green' http://shop/kubectl -n shop logs -l version=blue -c web --tail=2kubectl -n shop logs -l version=green -c web --tail=2

Optional: mirror live traffic to green

Mirroring sends a copy of each request to green while users still get blue's answer; green's responses are thrown away. Add it to the weighted route:

YAML
  - route:    - destination:        host: shop        subset: blue      weight: 100    - destination:        host: shop        subset: green      weight: 0    mirror:      host: shop      subset: green    mirrorPercentage:      value: 100.0

Watch green's logs and error rate under real traffic. Be careful with anything that writes: a mirrored order is still an order.

Step 4: switch, and switch back

Edit the weights to 0 for blue and 100 for green (kubectl -n shop edit virtualservice shop, or apply the changed file). Every sidecar picks up the change within seconds. To roll back, set them to 100 and 0. Steps such as 90/10 and 50/50 make it a canary instead. When green has carried all traffic long enough, remove the mirror, drop blue from the route and scale its Deployment to zero.

Traffic from outside the cluster

A VirtualService for the host shop applies to requests from inside the mesh. For traffic from outside, bind the same routing to Istio's ingress gateway (an Istio Gateway and gateways: on the VirtualService), or use the Gateway API's HTTPRoute, which Istio also implements, with the weights from part 3.

Things that catch people out

  • No sidecars, no routing. Pods created before injection was turned on, or a client outside the mesh, ignore the VirtualService and get plain round-robin across both versions.
  • Subset before route. Apply the DestinationRule first.
  • Port names. Name the Service port by protocol (http) so Istio treats it as HTTP; header rules need it.
  • Mirroring writes. Mirrored requests are real requests to green.

The blue/green series

  1. Blue/green with a Service selector: the pattern, and the version the exam asks for.
  2. Blue/green with an Ingress: switch the backend at the edge; weights with Traefik.
  3. Blue/green with the Gateway API: standard weights in an HTTPRoute, and a header to test green.
  4. Blue/green with Istio (this article): subsets, weights, mirroring live traffic to green.

Keep going

The exams test the pattern without a mesh. Practice it on a real cluster in the CKAD's Rollouts and release strategies module (blue/green and canary labs), and routing in the CKA's Ingress and network policy module.

More from the blog