GCE 网络负载均衡器将流量环回 VM

GCE Network Load Balancer loops traffic back to VM

在 GCE 上,使用网络负载均衡器 (NLB),我有以下场景:

1 VM with internal IP of 10.138.0.62 (no external IP)
1 VM with internal IP of 10.138.0.61 (no external IP)
1 NLB with a target pool (Backend) that contains both of these VMs
1 Health check that monitors a service on these VMs

简单的问题是,当这些虚拟机之一访问 NLB IP 地址时,请求会立即解析为发出请求的同一实例的 IP,它永远不会在两个虚拟机之间取得平衡,它永远不会成功到另一个虚拟机。即使发出请求的 VM 未通过健康检查。例如:

VM on 10.138.0.62 is in target pool of NLB and its service is healthy.
VM on 10.138.0.61 is in target pool of NLB and its service is NOT healthy.

从 10.138.0.61 上的第二个 VM 向 NLB 发出请求,即使同一台 VM 的健康检查失败,流量仍将传送给它自己。它基本上完全忽略了 NLB 和健康检查的事实,只是说 "If the VM is in the target pool for this NLB and it attempts contact with the IP of the NLB, loop the traffic back to itself".

请注意,如果我从 NLB 的目标池中删除 IP 10.138.0.61 上的 VM 并再次尝试连接,它会立即连接到仍在目标池中的另一个 VM,就像我期待它。如果我将 IP 10.138.0.61 上的虚拟机放回目标池中并尝试访问 NLB,它只会再次循环回 10.138.0.61

上的调用机器

谷歌搜索了一下,我看到这种行为发生在某些版本的 Windows 服务器及其 NLB 上,但我没想到会出现在 GCE 上。其他人看到过相同的行为吗?这只是我应该期望的已知行为吗?如果是这样,有什么解决方法吗?

这是按预期工作的。由于网络在虚拟环境中的配置方式,这将始终导致负载平衡 VM 将请求返回给自身而忽略健康检查状态。请查看提供的 link 以获得更多信息。