<p>In our current architecture, we are using Redis from MemoryStore, as a simple fast cache and pub-sub system.</p>
<p>For one of our services, we need to have a local very fast cache for a replicated service. The service would be hosted on GKE (Google Kubernetes Engine). The idea would be to have a Redis slave per node which would be the endpoint of any pod of our services.</p>
<p>Is it possible to use our MemoryStore Redis as a master of this system? If yes, is there a documentation or example somewhere for that? Or should we have a master Redis instance on our K8S cluster?</p>

Benjamin Barrois
<p>Not sure you can do it or not with MemoryStore. As much as i know it's managed service not provide a feature like that.</p>
<p>Generally what i have seen and used is <strong>Redis HA Kubernetes Deployment</strong> with <strong>Sentinel</strong>.</p>
<p>Helm : <a href="https://docs.bitnami.com/tutorials/deploy-redis-sentinel-production-cluster/" rel="nofollow noreferrer">https://docs.bitnami.com/tutorials/deploy-redis-sentinel-production-cluster/</a></p>
<p><strong>What is sentinel?</strong></p>
<p>Consider it like a sidecar proxy that manages the <strong>Master</strong> and <strong>Slave</strong> connections. it will return the Master and Slave IPs to you if you send request to it.</p>
<p>By default helm of Redis will deploy the Master POD with 2 slave POD and sentinel as a sidecar.</p>
<blockquote>
<p>When you say, <code>The idea would be to have a Redis slave per node which would be the endpoint of any pod of our services.</code></p>
</blockquote>
<p>On a note of Deploying Redis slave on each node might be easy to configure but connecting <strong>POD</strong> directly to that <strong>Slave</strong> on the same <strong>Node</strong> would be weird as all traffic goes using <strong>Kubernets service</strong>.</p>
<p>Yes, you can do it keeping the slave on each node but not sure how your service will connect to those <strong>slaves</strong> ?</p>
<p>Your application will be talking with <strong>Single</strong> <strong>Service of Kubernetes</strong>, that service will return the <strong>IP</strong> of <strong>Current</strong> <strong>Masters</strong> and <strong>Slave</strong> as per sentinel document.</p>
<p>Sentinel Documentaion : <a href="https://redis.io/topics/sentinel" rel="nofollow noreferrer">https://redis.io/topics/sentinel</a></p>
<p><strong>Extra note (Clustering Vs Sentinel):</strong></p>
<p>Redis clustering is distributed option while sentinel is good for HA and Replication as new Master will be always ready to handle.</p>
<p>Here one application example in <strong>Python</strong> :</p>
<pre><code>from redis import Sentinel
sentinel = Sentinel([('&lt;**Single K8s service Name**&gt;', 26379)], socket_timeout=0.1)
sentinel.discover_master('mymaster')
('127.0.0.1', 6379)
sentinel.discover_slaves('mymaster')
[('127.0.0.1', 6380)]
</code></pre>
<p><strong>Reference</strong> : <a href="https://github.com/redis/redis-py#sentinel-support" rel="nofollow noreferrer">https://github.com/redis/redis-py#sentinel-support</a></p>
