<p>I am trying to build a redis cluster with kubernetes on azure. And I am faced with the exact same problem when running different samples : <a href="https://sanderp.nl/running-redis-cluster-on-kubernetes-e451bda76cad" rel="nofollow noreferrer">sanderp.nl/running-redis-cluster-on-kubernetes</a> or <a href="https://github.com/zuxqoj/kubernetes-redis-cluster/blob/master/README-using-statefulset.md" rel="nofollow noreferrer">github.com/zuxqoj/kubernetes-redis-cluster</a></p>

<p>Everything goes well until I try to have the different nodes join the cluster with the <code>redis-trib</code> command.
At that time I face the infamous infinite "<strong>Waiting for the cluster to join ....</strong>" message. </p>

<p>Trying to see what is happening, I set up the loglevel of the redis pods to <code>debug</code> level. I then noticed that the pods do not seem to announce their correct ip when communicating together.
In fact it seems that the <strong>last byte of the ip is replaced by a zero</strong>. Say if pod1 has ip address 10.1.34.<strong>9</strong>, I will see in pod2 logs:</p>

<p>Accepted clusternode 10.1.34.<strong>0</strong>:<em>someport</em></p>

<p>So the pods do  not seem to be able to communicate back and the join cluster process never ends.</p>

<p>Now, if before running redis-trib, <strong>I enforce the cluster-announce-ip</strong> by running on each pod :</p>

<pre><code>redis-cli -h mypod-ip config set cluster-announce-ip mypod-ip
</code></pre>

<p><strong>the redis-trib command then completes successfully</strong> and the cluster is up and running.</p>

<p>But this not a viable solution as if a pod goes down and comes back, it may have changed ip and I will face the same problem when it will try to join the cluster.</p>

<p>Note that I do not encounter any problem when running the samples with minikube.</p>

<p>I am using flannel for kubernetes networking. Can the problem come from incorrect configuration of flannel ? Has anyone encountered the same issue ?</p>

<p>You can use <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">statefulsets</a> for deploying your replicas, so your pod will have a unique name always.</p>

<p>Moreover, you will be able to use <code>service</code> DNS-names as host. See this official doc <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">DNS for Services and Pods</a>. </p>

<p>The second example you shared, has another part for <a href="https://github.com/zuxqoj/kubernetes-redis-cluster/blob/master/README-using-statefulset.md" rel="nofollow noreferrer">redis cluster using statefulsets</a>. Try that out.</p>
