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!

1 Like