Unable to get cookie based session affinity to work for my application that has 2 pod replicas deployed in Azure managed AKS cluster. Nginx ingress controller does the routing of client requests from outside AKS to my application k8s internal service that uses matching label selectors to frontend the application pods. It works fine with 1 pod replica but in that case, session affinity is not applicable or not relevant.
nginx ingress controller is controlled by a horizontal pod scaler with minimum 2 replicas. I tried to scale it down to 1 replica to see if that would resolve this issue but that did not help. I have used this image of ingress controller: kubernetes-ingress-controller/nginx-ingress-controller:0.32.0
I have used these annotations in my ingress resource that are relevant to ingress cookie based session affinity.
nginx.ingress.kubernetes.io/affinity: cookie
nginx.ingress.kubernetes.io/affinity-mode: persistent
nginx.ingress.kubernetes.io/session-cookie-expires: "172800"
nginx.ingress.kubernetes.io/session-cookie-max-age: "172800"
nginx.ingress.kubernetes.io/session-cookie-name: app-cookie