<p>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 ?</p>

<p>Thanks,</p>

<p>SR</p>

Sreeni
<p>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. </p>

<p>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.</p>

<p>Some pointers to the solution</p>

<ul>
<li><p><a href="https://www.jeroenreijn.com/2015/09/testing-session-replication-with-docker-compose-redis-spring-session.html" rel="nofollow noreferrer">Using Redis for external session data</a></p></li>
<li><p><a href="https://github.com/nginxinc/kubernetes-ingress/tree/master/examples/session-persistence" rel="nofollow noreferrer">Sticky sessions</a> - this approach needs using Nginx as an ingress controller</p></li>
</ul>
