<p>I am login kubernetes's(v1.15.2) pod to check current redis cluster ip,but the problem is redis cluster(redis:5.0.1-alpine) ip is not current pod's ip:</p>

<pre><code>~ ⌚ 23:45:03
$ kubectl exec -it redis-app-0 /bin/ash
/data # ifconfig
eth0      Link encap:Ethernet  HWaddr 02:42:AC:1E:E0:1E
          inet addr:172.30.224.30  Bcast:172.30.231.255  Mask:255.255.248.0
          UP BROADCAST RUNNING MULTICAST  MTU:1450  Metric:1
          RX packets:78447 errors:0 dropped:0 overruns:0 frame:0
          TX packets:64255 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:74638073 (71.1 MiB)  TX bytes:74257972 (70.8 MiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:3922 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3922 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:297128 (290.1 KiB)  TX bytes:297128 (290.1 KiB)

/data # /usr/local/bin/redis-cli -c
127.0.0.1:6379&gt; cluster nodes
a1ecebe5c9dc2f9edbe3c239c402881da10da6de 172.30.224.22:6379@16379 myself,master - 0 1582644797000 0 connected
127.0.0.1:6379&gt;
</code></pre>

<p>the pod's ip is:172.30.224.30,and redis ip is:172.30.224.22,what is the problem?is it possible to fix it?</p>

Dolphin
<p>How is this IP defined in your redis config ? Redis must've taken it from somewhere. Keep in mind that <code>Pod</code> ip is subject to change when the <code>Pod</code> is recreated so you have no guarantee that IP address defined in your <strong>Redis node</strong> statically will remain unchanged. I would even say that you can be almost 100% sure that it will change.</p>

<p>You can check IP address of a particular interface in a few ways. One of them is by running:</p>

<pre><code>hostname -I | awk '{print $1}'
</code></pre>

<p>You can try to add an <strong>init container</strong> to your <code>Pod</code> running simple bash script which would check current host ip address e.g. using the above command and then would populate redis config accordingly. But it seems to me an overkill and I'm almost sure it can be done more easily. If your <strong>redis node</strong> by default binds to <strong>all IP addresses</strong> (<code>0.0.0.0</code>), <code>cluster nodes</code> output should show you current ip address of your <code>Pod</code>.</p>

<p>Are you providing <strong>Redis</strong> configuration to your Pod via some <code>ConfigMap</code> ?</p>

<p>Please share more details related to your <code>Deployment</code> so you can get more accurate answer that resolves your particular issue.</p>
