<p>How can I share the Spring cache between replicated microservices in kubernetes?
Which technology should I use?
The solution should be able to support an high available configuration (e.g.: master/slave; active-active DR and so on).</p>
<p>Please provide the spring boot configuration as well if possible.</p>

<p>Spring cache has a concept of cache providers - technologies standing behind the caching implementation.</p>
<p>By default the cache is implemented in-memory, so its not replicated in any manner. However you can configure it to run, say, with Redis. <a href="https://dzone.com/articles/quickstart-how-to-use-spring-cache-on-redis" rel="nofollow noreferrer">See this tutorial for technical implementation aspects</a></p>
<p>In this case the same redis instance should be accessible from all kubernetes nodes running the pod of your application and you will have distributed cache.</p>
<p>Depending on your actual needs you can also check the integration with <a href="https://mkyong.com/spring/spring-caching-and-ehcache-example/" rel="nofollow noreferrer">EHcache</a> or <a href="https://hazelcast.com/blog/spring-boot/" rel="nofollow noreferrer">Hazelcast</a>. I'm sure other options also exist but this should give a direction.</p>
