Session Affinity timeout

I am using ClientIP in sessionAffinity (in my service configuration), want to know more about session affinity timeout.

I wanted to achieve HA b/w websocket processes that is the reason for configuring service with sesssion affinity.

In my experiment, I had two pods which had to communicate to a process outside the cluster, I had kept the session affinity timeout to 120 seconds, my expectation was after every 120 seconds the connection b/w external process and the pod would get switched to the other pod (as there are 2 pods), but I didn’t see this happening consistently. Is it that if connection is stable , it will not switch?

It will be helpful if I get more clarity.


Cluster information:

Kubernetes version:

➜ kubectl version  
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.0", GitCommit:"cb303e613a121a29364f75cc67d3d580833a7479", GitTreeState:"clean", BuildDate:"2021-04-08T16:31:21Z", GoVersion:"go1.16.1", Compi
ler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.10", GitCommit:"62876fc6d93e891aa7fbe19771e6a6c03773b0f7", GitTreeState:"clean", BuildDate:"2020-10-15T01:43:56Z", GoVersion:"go1.13.15", Com
piler:"gc", Platform:"linux/amd64"}
WARNING: version difference between client (1.21) and server (1.18) exceeds the supported minor version skew of +/-1

Cloud being used: (put bare-metal if not on a public cloud) : bare-metal
Host OS: Ubuntu 18.04


I have nodejs based real-time chatting application and it is using websocket. It is deployed on AkS and application gateway ingress is used to expose but websocket connection is not established it is showing 502 error.

If you have any solution to implement websocket connection on kubernetes pods then please share with me