0

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.

theone
  • 1
  • 1
  • `But I need a webserver either apache or Nginx in front of my application servers to manage 100+ redirection rules or rewrite rule e.t.c.` I'm not sure what exactly you need, you have 100+ services and every service need his own session-cookie? e.g. you could try with something like [this](https://stackoverflow.com/questions/59272484/sticky-sessions-on-kubernetes-cluster). – Jakub Aug 27 '20 at 07:26
  • I don't see anything that looks like a *programming question related to the Apache HTTP Server* (from [tag:apache] tag description), the only mention is that you say you *might need something like* it. Which makes your problem off-topic for stackoverflow (see [help/on-topic]). When you add the apache tag again, please provide Apache-httpd related code that makes the question relevant (and programming-relevant) to your code. Hint: httpd doesn't generate JSESSIONID cookies, other Apache products (e.g. like tomcat) do. Note: Q for software recommendations (httpd vs nginx) are off topic as well. – Olaf Kock Aug 27 '20 at 11:45

0 Answers0