I have an k8s nginx server which is connecting to my statefulset application servers .
I am now trying to achieve sticky sessions based on JESSIONID in the cookie. I have nginx ingress controller which directs all requests to k8s nginx service. But my nginx service is not able to maintain the sticky seesion between application server pods therefore I am not able to maintain user session in my application.
If I am connecting Ingress controller directly to application service with config nginx.ingress.kubernetes.io/session-cookie-name=JESSIONID its working as expected.
But I need a webserver either apache or Nginx in front of my application servers .
Is there is any way to achieve this? OR how we can configure statefulset pods directly inside Upstream block of Nginx or as a worker in apache?
I need below structure Ingress ->Webserver-> front application Currently, I have below config
nginx.ingress.kubernetes.io/session-cookie-name=JESSIONID
- backend :
serviceName: nginx-web-svc
servicePort: 80
In my nginx statefulset I have below config in nginx.conf file
location / {
proxy_pass app-svc:3000;
}
app-svc is for Application statefulset having 3 replicas (3 pods) .Its working but not managing stickiness between application pods. If I bypass webserver and directly use below ingress config it's working like charm.
nginx.ingress.kubernetes.io/session-cookie-name=JESSIONID
- backend :
serviceName: app-svc
servicePort: 3000
But I need webserver in front of my app servers .How to achieve stickiness in that scenario.