<p>I've deployed the redis helm <a href="https://github.com/bitnami/charts/tree/master/bitnami/redis" rel="nofollow noreferrer">chart</a> on k8s with Sentinel enabled.</p>
<p>I've set up the Master-Replicas with Sentinel <a href="https://github.com/bitnami/charts/tree/master/bitnami/redis#master-replicas-with-sentinel" rel="nofollow noreferrer">topology</a>, it means one master and two slaves. Each pod is running both the redis and sentinel container successfully:</p>
<pre><code>NAME             READY   STATUS    RESTARTS   AGE     IP             NODE
my-redis-pod-0   2/2     Running   0          5d22h   10.244.0.173   node-pool-u
my-redis-pod-1   2/2     Running   0          5d22h   10.244.1.96    node-pool-j
my-redis-pod-2   2/2     Running   0          3d23h   10.244.1.145   node-pool-e
</code></pre>
<p>Now, I've a python script that connects to redis and discovers the master by passing it the pod's ip.</p>
<pre><code>sentinel = Sentinel([('10.244.0.173', 26379),
                     ('10.244.1.96',26379),
                     ('10.244.1.145',26379)],
                  sentinel_kwargs={'password': 'redispswd'})

host, port = sentinel.discover_master('mymaster')
redis_client = StrictRedis(
            host=host,
            port=port,
            password='redispswd')
</code></pre>
<p>Let's suposse the master node is on <em>my-redis-pod-0</em>, when I do <code>kubectl delete pod</code> to simulate a problem that leads me to loss the pod, Sentinel will promote one of the others slaves to master and kubernetes will give me a new pod with redis and sentinel.</p>
<pre><code>NAME             READY   STATUS    RESTARTS   AGE     IP             NODE
my-redis-pod-0   2/2     Running   0          3m      10.244.0.27    node-pool-u
my-redis-pod-1   2/2     Running   0          5d22h   10.244.1.96    node-pool-j
my-redis-pod-2   2/2     Running   0          3d23h   10.244.1.145   node-pool-e
</code></pre>
<p>The question is, how can I do to tell Sentinel to <em>add</em> this new ip to the list automatically (without code changes)?</p>
<p>Thanks!</p>

Martín C.
<p>Instead of using IPs, you may use the dns entries for a headless service.</p>
<p>A headless service is created by explicitly specifying</p>
<pre><code>ClusterIP: None
</code></pre>
<p>Then you will be able to use the dns entries as under, where redis-0 will be the master</p>
<pre><code>#syntax
pod_name.service_name.namespace.svc.cluster.local

#Example
redis-0.redis.redis.svc.cluster.local
redis-1.redis.redis.svc.cluster.local
redis-2.redis.redis.svc.cluster.local
</code></pre>
<p>References:
<a href="https://stackoverflow.com/questions/52707840/what-is-a-headless-service-what-does-it-do-accomplish-and-what-are-some-legiti">What is a headless service, what does it do/accomplish, and what are some legitimate use cases for it?</a></p>
<p><a href="https://www.containiq.com/post/deploy-redis-cluster-on-kubernetes" rel="nofollow noreferrer">https://www.containiq.com/post/deploy-redis-cluster-on-kubernetes</a></p>
