Delete Pods waiting until the sticky sessions expire

Cluster information:

Kubernetes version: 1.17.4
Cloud being used: bare-metal
Host OS: Linux Master with Windows Nodes
CNI and version: flannel
CRI and version: docker 19.3.8

Hi,

We have a very-stateful Web-Application (tomcat/java), which needs sticky sessions. When we scale down (upgrading to new version or to free resources), we need to stop sending new sessions to the pod, while keep sending bound sessions to the corresponding Pod.

Using preStop-Hook and TerminationGracePeriod we are able to delay the shutdown if the pod has active sessions. But the pod is already set to “Terminating”-State and removed from the endpoints list, which means the pod is no longer getting any traffic and the sessions are “lost”.

Is there any direct solution from Kubernetes for this problem? This should be a common issue among legacy web applications.
Should we look for a third-party solution? We tried with https://haproxy-ingress.github.io, which has “drain-support” flag, but it did not work (maybe there was a configuration problem).

Thanks!

2 Likes

Hi @nahn ! You are in a surprisingly similar boat to me :slight_smile: HAProxy Session Persistence v.s. Drain State - Help! - HAProxy community
Any insights you can share here? In particular, I’m struggling with tidying up/draining our pods and then re-assessing whether we still want to delete them.

Of course, the most important part is definitely ensuring traffic from bound pods can still get in the door. Did you ever consider using a finalizer to intercept the delete call, set the pod to drain, and only after finishing the drain process resume the (now shortened) deletion?

Hi, did you get any solution. facing same issue on nginx-ingress.?