When scale up pod in k8s ingress session affinity error

5/8/2019

I am running a python application which is having react bundle.

Currently, i am running single pod of application everything seems to work fine but when i was scaling up to pod number 2-3 it's creating an issue in some case not able to login into the application.

in ingress, i have added ingress yaml config is :

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: admin-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    certmanager.k8s.io/cluster-issuer: admin-prod
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/secure-backends: "true"
    nginx.ingress.kubernetes.io/affinity: "cookie"
    nginx.ingress.kubernetes.io/session-cookie-name : "session"
spec:
  tls:
  - hosts:
    - domain
    secretName: admin-prod
  rules:
  - host: domain
    http:
      paths:
      - path: /
        backend:
          serviceName: admin-service
          servicePort: 80
-- Harsh Manvar
docker
google-kubernetes-engine
kubernetes

1 Answer

5/8/2019

It appears like you are storing user session info in cookie.

nginx.ingress.kubernetes.io/affinity: "cookie"

the above setting would enable sticky session using the cookie. say, user is connected to replica-1. his session info is stored in cookie. he gets logged out and logs in back, he would be taken to replica-1.

-- P Ekambaram
Source: StackOverflow