简体   繁体   English

为什么集群节点的 ip 不是当前 pod 的 ip

[英]why cluster node's ip is not current pod's ip

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:我正在登录 kubernetes 的(v1.15.2)pod 来检查当前的 redis 集群 ip,但问题是 redis cluster(redis:5.0.1-alpine) ip 不是当前 pod 的 ip:

~ ⌚ 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> cluster nodes
a1ecebe5c9dc2f9edbe3c239c402881da10da6de 172.30.224.22:6379@16379 myself,master - 0 1582644797000 0 connected
127.0.0.1:6379>

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? pod的ip是:172.30.224.30,redis的ip是:172.30.224.22,有什么问题吗?能解决吗?

How is this IP defined in your redis config ?这个 IP 在你的 redis 配置中是如何定义的? Redis must've taken it from somewhere. Redis 一定是从某个地方拿走了它。 Keep in mind that Pod ip is subject to change when the Pod is recreated so you have no guarantee that IP address defined in your Redis node statically will remain unchanged.请记住,重新创建Pod时, Pod ip 可能会发生变化,因此您无法保证在Redis 节点中静态定义的 IP 地址将保持不变。 I would even say that you can be almost 100% sure that it will change.我什至可以说你几乎可以 100% 确定它会改变。

You can check IP address of a particular interface in a few ways.您可以通过多种方式检查特定接口的 IP 地址。 One of them is by running:其中之一是运行:

hostname -I | awk '{print $1}'

You can try to add an init container to your Pod running simple bash script which would check current host ip address eg using the above command and then would populate redis config accordingly.您可以尝试向运行简单 bash 脚本的Pod添加一个init 容器,该脚本将检查当前主机 ip 地址,例如使用上述命令,然后相应地填充 redis 配置。 But it seems to me an overkill and I'm almost sure it can be done more easily.但这对我来说似乎有点矫枉过正,我几乎可以肯定它可以更轻松地完成。 If your redis node by default binds to all IP addresses ( 0.0.0.0 ), cluster nodes output should show you current ip address of your Pod .如果您的redis 节点默认绑定到所有 IP 地址( 0.0.0.0 ),则cluster nodes输出应显示您Pod当前 IP 地址。

Are you providing Redis configuration to your Pod via some ConfigMap ?您是否通过一些ConfigMap向您的 Pod 提供Redis配置?

Please share more details related to your Deployment so you can get more accurate answer that resolves your particular issue.请分享与您的Deployment相关的更多详细信息,以便您获得更准确的答案来解决您的特定问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么 pod 的 localhost 在 k8s 中解析为节点 ip? - why is localhost of pod resolved to node ip in k8s? 寻找一种方法来确定为什么离开我的集群的数据包会保留它的 pod IP - Looking for a way to determine why a packet leaving my cluster would keep it's pod IP 为什么在 GKE(私有集群)中目的地只能看到 Pod IP 而不是 Node IP - Why in GKE (Private Cluster) the destination only sees Pod IP instead of Node IP 按名称解析pod的IP - Resolving a pod's IP by name 无法 ping 到 kubernetes 中工作节点的 pod ip - Can not ping to pod's ip of worker node in kubernetes 如何使用节点的 IP 而不是 pod IP 使用 IPv6 进行出口? - How to use node's IP instead of pod IP for egress using IPv6? 我们在 pod 中获得的公共 IP 是否与它正在运行的 Node 的公共 IP 不同? - Is public IP we get in pod different from Node's public IP it is running? GKE - 在运行时绕过 Pod LoadBalancer(Pod 的外部 IP)到 Pod 的容器的 IP 以用于 WebSocket 目的 - GKE - Bypass Pod LoadBalancer (Pod's external IP) to Pod's container's IP at runtime for WebSocket purpose k8s Pod 1 获取错误 pod 2 的 ip 地址 - k8s Pod 1 get wrong pod 2's ip address 负载均衡器外部IP与K3s集群中节点的内部IP相同 - Load Balancer External IP is the same as Internal IP of node in K3s cluster
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM