SpringBoot controler redirect across docker poods

7/26/2018

We have a SpringBoot Web app docker container deployed in Kubernetes with 3 replicas. when the controller redirects to a different url within the same controller, we pass an object via the flashAttributes. When we run 1 pod, everything works. But when I scale to 3 pods, the object comes with all internal attributes set to Null. Has anyone come across the issue ? If so prescribe a solution ?

Thanks,

SR

-- Sreeni
docker
kubernetes
redirect
spring-boot

1 Answer

7/26/2018

Kubernetes can send multiple requests from a session to different pod within a deployment. That's why the data is lost because the data might in memory for one pod but another pod will not have that data at all.

To avoid this - you can either maintain the session cache in an external store like Redis or use sticky sessions so that for given session requests are sent to the same pod.

Some pointers to the solution

-- Vishal Biyani
Source: StackOverflow