Cheat notes · Module 06 · Traffic
Istio: exact weights and header routes
A five-minute review for when you have done this module and want it back in your head. Open the full module for the steps and the lab, or the full text to print.
The idea
Without a traffic router, a weight is a pod count. With Istio, the Rollout writes the weights into a VirtualService and the mesh sends exactly that share of requests, however many pods there are. It can also route a test header to the canary before any user gets it, and the sidecars give mutual TLS between pods.
Remember
- Three charts, pinned:
base(CRDs),istiod,gateway(releaseistio-ingress), Istio 1.30.8, sidecar mode. istio-injection: enabledoncheckout-prodandloadgen; existing pods need a restart to get a sidecar.- Two Services:
checkout(stable) andcheckout-canary; the VirtualService routeprimaryhas both with weights. setCanaryScaleruns one canary pod with no traffic;setHeaderRoutesendsx-canary: trueto it.- Argo CD ignores the weights (
ignoreDifferencesplusRespectIgnoreDifferences=true), because the controller changes them. - PeerAuthentication STRICT in prod: only pods with a sidecar can call checkout.
Pitfalls
- Argo CD resetting the weights to 100/0 in the middle of a release. Ignore
.spec.http[].route[].weightand respect it on sync. - STRICT mTLS before the callers have sidecars: the load generator gets connection resets.
- Starting analysis at the header step: nobody but testers sends requests, so there is no data.
Commands
kubectl argo rollouts restart checkout -n checkout-prod | Restart the pods so they get a sidecar |
kubectl -n checkout-prod get virtualservice checkout -o jsonpath='{.spec.http[0].route[*].weight}' | The weights right now |
kubectl -n istio-ingress port-forward svc/istio-ingress 8090:80 | The mesh's front door on localhost:8090 |
curl -s -H 'x-canary: true' http://checkout.localtest.me:8090/ | jq -r .version | What testers get |
checkout-config helm/prod.yaml (module 06, steps)
canary:
trafficRouting: istio
steps:
- setCanaryScale: { replicas: 1 }
- setHeaderRoute:
name: canary-header
match:
- headerName: x-canary
headerValue: { exact: "true" }
- pause: {}
- setWeight: 5
- pause: { duration: 2m }
- setWeight: 25
- pause: { duration: 2m }
- setWeight: 50
- pause: { duration: 2m }
- setHeaderRoute: { name: canary-header }
analysis:
templates: [success-rate]
startingStep: 4
Test yourself
Answer in your head first, then open the answer.
What does setWeight: 5 mean with Istio?
Exactly 5% of requests go to the canary, whatever the pod count.
How do testers reach a canary before users do?
A header route: requests with x-canary: true go to the canary Service.
Why does the checkout-prod Application ignore VirtualService weights?
The Rollout controller changes them during a release; Argo CD must not reset them.
Where module 06 leaves you: Istio 1.30.8 runs; checkout-prod and the load generator have sidecars. Prod releases through a VirtualService: one canary pod, a tester route on the header x-canary: true, then 5/25/50%. Prod runs 6.12.0 with mTLS STRICT.