Skip to content
Tutorials Center
My learning

Topics

Lesson 35 of 36 ยท Projects and Practice

Project: Progressive Canary Rollout for Istio Bookinfo

A hands-on project plan: expose Istio's Bookinfo sample, shift traffic to reviews v2 in steps, watch the metrics, add timeouts, retries and a breaker, and automate promote or rollback decisions.

In this project you take a sample application through a full, safe release. You will expose it through an ingress gateway, define versions, shift traffic to a new version step by step, watch the golden signals and decide to promote or roll back. It ties together gateways, routing, resilience and observability.

The product cannot run on this site, so the project is described precisely as commands and manifests for your own cluster (kind, minikube or a cloud cluster). A Python stand-in simulates the rollout decision loop so you can design the thresholds before you touch a cluster. No output of real commands is shown here.

The application

Bookinfo is the sample application shipped in the Istio release folder (samples/bookinfo). It has four services: productpage (the front end), details, reviews (three versions: v1 shows no stars, v2 shows black stars and calls ratings, v3 shows red stars) and ratings.

flowchart LR
  U["user"] --> GW["ingress gateway"] --> PP["productpage"]
  PP --> D["details"]
  PP --> R["reviews v1 / v2 / v3"]
  R -.->|"v2 and v3 only"| RT["ratings"]

Phase 1: install and expose

Terminal
kubectl create namespace bookinfo
kubectl label namespace bookinfo istio-injection=enabled
kubectl apply -n bookinfo -f samples/bookinfo/platform/kube/bookinfo.yaml
kubectl apply -n bookinfo -f samples/bookinfo/networking/bookinfo-gateway.yaml
istioctl analyze -n bookinfo

Find the gateway address and open http://$GATEWAY/productpage. With no routing rules, requests to reviews rotate across all three versions: refresh the page and the stars change. That is the starting problem: you want control.

Phase 2: declare versions and pin everything to v1

Create a DestinationRule that defines a subset per version label, then a VirtualService that sends all reviews traffic to v1:

YAML
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata: { name: reviews, namespace: bookinfo }
spec:
  host: reviews
  subsets:
    - { name: v1, labels: { version: v1 } }
    - { name: v2, labels: { version: v2 } }
    - { name: v3, labels: { version: v3 } }
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata: { name: reviews, namespace: bookinfo }
spec:
  hosts: [reviews]
  http:
    - route:
        - destination: { host: reviews, subset: v1 }

Reload the page: no stars, every time. Production behavior is now stable and explicit.

Phase 3: test v2 with one user, then a percentage

First route only a test user (identified by a header the front end sets, such as end-user: jason) to v2:

YAML
  http:
    - match:
        - headers: { end-user: { exact: jason } }
      route:
        - destination: { host: reviews, subset: v2 }
    - route:
        - destination: { host: reviews, subset: v1 }

Log in as that user in the sample, check the black stars appear, and confirm everybody else is unaffected. Then shift traffic by weight, repeating the apply with new numbers: 95/5, 90/10, 50/50, 0/100.

YAML
      route:
        - destination: { host: reviews, subset: v1 }
          weight: 90
        - destination: { host: reviews, subset: v2 }
          weight: 10

Phase 4: add guard rails

Before increasing traffic add resilience (see the lessons on timeouts and retries and circuit breaking): a timeout: 2s and one retry on the reviews route, plus outlier detection on the DestinationRule. Then generate load (for example with fortio or a simple curl loop) and watch:

  • Kiali's graph: the share of requests flowing to each version and the health color.
  • Grafana's Workload dashboard: success rate and p99 latency per version, reviews-v1 against reviews-v2 (see Kiali and Grafana).
  • Prometheus: the query for the 5xx ratio filtered by destination_version="v2".

To test the safety net, deploy a broken build of v2 or use fault injection to return 500s for part of its traffic, and see the error ratio rise.

Phase 5: promote or roll back

A rollout is promoted when the new version stays within your thresholds at each step for a minimum time. It is rolled back immediately when it breaches them: simply reapply the VirtualService with 100 percent on v1. Tools such as Argo Rollouts or Flagger automate exactly this loop with Istio traffic shifting.

Try it: simulate the rollout controller

Design your thresholds here first. The simulation feeds a fixed list of error ratios per step into the decision rules.

Python Canary controller decision loop

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Try it: generate the VirtualService for each step

Python Weighted VirtualService generator

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Stretch goals

  1. Add a timeout and retries, then inject a delay in v2 and watch the UT flag.
  2. Mirror a copy of production traffic to v2 (mirror and mirrorPercentage) before sending real users.
  3. Add a Telemetry resource that logs only requests with status 500 or higher.
  4. Write the same routing as a Gateway API HTTPRoute with weighted backendRefs (see Gateway API).

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What defines the subsets v1, v2 and v3 that a VirtualService routes to?

    Subsets are named groups of endpoints selected by labels in a DestinationRule.
  2. 2. Why test with one user or header before shifting a percentage?

    Header-based routing lets you verify the canary with a controlled request path first.
  3. 3. How do you roll back a weighted rollout fastest?

    Because routing is configuration, rollback is applying the previous weights.
  4. 4. Which signals should gate each promotion step?

    Golden signals such as errors and p99 latency decide whether to continue.

Summary

  • Expose Bookinfo through the gateway, pin traffic to v1, then test v2 by header and by weight.
  • Add timeouts, retries and outlier detection before raising traffic.
  • Watch errors and latency per version; promote on healthy, roll back by reapplying the stable route.
  • Automating the loop is what progressive-delivery tools do.

Next: Project: a zero-trust mesh audit