I use ingress nginx controller with session stickiness. When debugging the application I found out that the service switch to different pod after the initial request received but subsequent requests continue on the same pod thereafter. Is this an expected behaviour? THanks!
I believe you are experiencing that behaviour as the service object acts as an internal loadbalancer, separate from the ingress. You may want offload the session information into something within your apps deployment.
What do you mean? Can you provide more details? Thanks.
The nginx controller will just direct the traffic to the service which will then act like a load balancer and send traffic to a pod. This means that the pod is unaware of what is happening at the nginx-controller level.
The way the teams I worked with have done this in the past is to have a datastore where the sessions exist that the pods can get the session data from.
I did a little digging around and looks like there is a way to get the client to stick to a certain pod via
cookie affinity . Here’s a quick tutorial and here is the ingress yaml example . I have not tried this method but it sounds like it is worth giving a shot.
That’s exactly what I use from ubuntu/microk8s. No, it doesn’t help.