flagger icon indicating copy to clipboard operation
flagger copied to clipboard

Why not support nginx session sticky/affinity?

Open mumubin opened this issue 2 years ago • 3 comments

Describe the feature

As far as I know, nginx itself also supports session sticky/affinity, but in flagger's documentation, session affinity only applies to istio situations . Is it assessed that the technology is not feasible, or is there not enough development resources to realize it?

Proposed solution

If it's technically possible, I can try to offer PR

mumubin avatar Aug 24 '23 01:08 mumubin

Seems to be added support for canary and session affinity by this PR: https://github.com/kubernetes/ingress-nginx/pull/7371

Would be awesome to have support for this with nginx!

akselleirv avatar Sep 01 '23 13:09 akselleirv

now that Gateway API has ResponseHeaderModifier as a part of its standard installation, we are adding session affinity for Gateway API. whenever ingress-nginx starts supporting Gateway API, Flagger will automatically support session affinity for Nginx.

aryan9600 avatar Sep 08 '23 12:09 aryan9600

Thanks @akselleirv 's doc. Base on this doc, I add some annotations on the ingress. Then the podinfo can support session affinity for both podinfo-canary and podinfo-primary service. Maybe this is a workaround, you can have a try,

Example: add session-affinity annotations in ingress yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: podinfo
  namespace: flagger
  labels:
    app: podinfo
  annotations:
    nginx.ingress.kubernetes.io/affinity: cookie
    nginx.ingress.kubernetes.io/affinity-mode: balanced
    nginx.ingress.kubernetes.io/affinity-canary-behavior: sticky
    nginx.ingress.kubernetes.io/session-cookie-max-age: "172800"
    nginx.ingress.kubernetes.io/session-cookie-expires: "172800"
    ingressClassName: ingress-internal
spec:
  rules:
    - host: "podinfo.flagger.lab.xxx.int.xxxxx.com"
      http:
        paths:
          - pathType: Prefix
            path: "/"
            backend:
              service:
                name: podinfo
                port:
                  number: 80

mumubin avatar Sep 18 '23 07:09 mumubin