@@ -10,6 +10,8 @@ Flagger can run automated application analysis, promotion and rollback for the f
1010 * Kubernetes CNI, Istio, Linkerd, App Mesh, NGINX, Contour, Gloo Edge, Open Service Mesh, Gateway API
1111* ** Blue/Green Mirroring** \( traffic shadowing\)
1212 * Istio
13+ * ** Canary Release with Session Affinity** \( progressive traffic shifting combined with cookie based routing\)
14+ * Istio
1315
1416For Canary releases and A/B testing you'll need a Layer 7 traffic management solution like
1517a service mesh or an ingress controller. For Blue/Green deployments no service mesh or ingress controller is required.
@@ -393,3 +395,58 @@ After the analysis finishes, the traffic is routed to the canary (green) before
393395triggering the primary (blue) rolling update, this ensures a smooth transition
394396to the new version avoiding dropping in-flight requests during the Kubernetes deployment rollout.
395397
398+ # # Canary Release with Session Affinity
399+ This deployment strategy mixes a Canary Release with A/B testing. A Canary Release is helpful when
400+ we're trying to expose new features to users progressively, but because of the very nature of its
401+ routing (weight based), users can land on the application's old version even after they have been
402+ routed to the new version previously. This can be annoying, or worse break how other services interact
403+ with our application. To address this issue, we borrow some things from A/B testing.
404+
405+ Since A/B testing is particularly helpful for applications that require session affinity, we integrate
406+ cookie based routing with regular weight based routing. This means once a user is exposed to the new
407+ version of our application (based on the traffic weights), they're always routed to that version, i.e.
408+ they're never routed back to the old version of our application.
409+
410+ You can enable this, by specifying `.spec.analsyis.sessionAffinity` in the Canary (only Istio is supported) :
411+
412+ ` ` ` yaml
413+ analysis:
414+ # schedule interval (default 60s)
415+ interval: 1m
416+ # max number of failed metric checks before rollback
417+ threshold: 10
418+ # max traffic percentage routed to canary
419+ # percentage (0-100)
420+ maxWeight: 50
421+ # canary increment step
422+ # percentage (0-100)
423+ stepWeight: 2
424+ # session affinity config
425+ sessionAffinity:
426+ # name of the cookie used
427+ cookieName: flagger-cookie
428+ # max age of the cookie (in seconds)
429+ # optional; defaults to 86400
430+ maxAge: 21600
431+ ` ` `
432+
433+ ` .spec.analysis.sessionAffinity.cookieName` is the name of the Cookie that is stored. The value of the
434+ cookie is a randomly generated string of characters that act as a unique identifier. For the above
435+ config, the response header of a request routed to the canary deployment during a Canary run will look like :
436+ ` ` `
437+ Set-Cookie: flagger-cookie=LpsIaLdoNZ; Max-Age=21600
438+ ` ` `
439+
440+ After a Canary run is over and all traffic is shifted back to the primary deployment, all responses will
441+ have the following header :
442+ ` ` `
443+ Set-Cookie: flagger-cookie=LpsIaLdoNZ; Max-Age=-1
444+ ` ` `
445+ This tells the client to delete the cookie, making sure there are no junk cookies lying around in the user's
446+ system.
447+
448+ If a new Canary run is triggered, the response header will set a new cookie for all requests routed to
449+ the Canary deployment :
450+ ` ` `
451+ Set-Cookie: flagger-cookie=McxKdLQoIN; Max-Age=21600
452+ ` ` `
0 commit comments