If a pod die, so does the cookies and sessions it issued disappear?

4/10/2020

kubernetes newbie here, so this question might not make sense and apologies in advance. Please bear with me.

So as I understand it, the Ingress Controller communicates directly to the pods. One of the reasons is so it maintains co-relation with user cookies and sessions with the pod that issue them to the user.

But when the pod dies, so does those cookies and sessions? So the user ex. will have to re-login for example. Is that right?

Thanks in advance.

-- Jplus2
kubernetes
kubernetes-ingress

2 Answers

4/10/2020

There's no state stored by the ingress controller in relation to the user session or cookies. If your pod is not persisting state somewhere for the incoming session identifier, and is just persisting to local disk or memory for example, then you will lose that state when the pod is restarted. Similarly, if your workload is scaled to more than 1 replica, and your session is only persisted to disk or memory, then when the request is routed to the other replica the session will not exist.

-- snormore
Source: StackOverflow

4/10/2020

From the docs.

When the backend server is removed, the requests are re-routed to another upstream server. This does not require the cookie to be updated because the key's consistent hash will change.

Assuming that you have more than one replicas(via deployment/replication controller) of the pod, this means if one of the replica pod dies, kubernetes removes it from the list of endpoints of the service, and consequently Lua balancer in nginx removes that endpoint from its upstream server list, which means consistent hash ring gets rebuilt and the request will be rerouted to other replica pods keeping the same session cookie.

Whether the user need to re-login or not depends on how the application stores or uses the cookie to decide if a user is logged in or not.

-- Arghya Sadhu
Source: StackOverflow