<p>I have a redis sentinel master slave setup with 1 master and 3 slaves and this is in Kubernetes environment.In the spring lettuce configuration, I have to specify the sentinels URLs with port numbers. How should I specify the URL for each sentinel? <a href="https://docs.spring.io/spring-data/data-redis/docs/current/reference/html/#redis:sentinel" rel="nofollow noreferrer">Spring doc</a> specifies IP and port. In the local it's ok but when in k8s, how should I configure? I installed the set up with <a href="https://github.com/bitnami/charts/tree/master/bitnami/redis" rel="nofollow noreferrer">bitnami redis chart</a>. Below is how it's done locally.</p>
<pre class="lang-java prettyprint-override"><code>@Bean
public RedisConnectionFactory lettuceConnectionFactory() {
    RedisSentinelConfiguration sentinelConfig = 
        new RedisSentinelConfiguration().master(&quot;mymaster&quot;)
                                        .sentinel(&quot;127.0.0.1&quot;, 26379)
                                        .sentinel(&quot;127.0.0.1&quot;, 26380);
    return new LettuceConnectionFactory(sentinelConfig);
}
</code></pre>
<p>Thanks</p>

sachin
<p>First thing -> using the bitnami helm chart is the right way to do things.</p>

<p>Although a bit of a different implementation, heres how we implemented the same master slave setup AND also avoided the above problem while ensuring the MAXIMUM availability we ever witnessed (less than 2 secs Downtime for master)</p>

<ul>
<li><p>We made two services - one for master and another for slaves.</p></li>
<li><p>a PV PVC that was shared between the slaves and master where ONLY Master would write and slaves would only read from PV</p></li>
<li><p>this way we could always ensure that there was 1 pod running ALL time for master and N replicas behind the headless service for slaves.</p></li>
</ul>

<p>In application slaves and master URL's would always be different, thus ensuring a clear "WRITE" and "READ" isolation and improving the stability of system with almost no failures for reads.</p>
