之前我们一直使用ingress网关暴露服务,现在有些pod直接使用LoadBalancer向外提供服务,突然开发小伙伴说程序获取的IP不对
这里引用官方的一段话:
Source IP for Services with Type=LoadBalancer
Packets sent to Services with Type=LoadBalancer are source NAT’d by default, because all schedulable Kubernetes nodes in the Ready state are eligible for load-balanced traffic. So if packets arrive at a node without an endpoint, the system proxies it to a node with an endpoint, replacing the source IP on the packet with the IP of the node (as described in the previous section).
调整方式
#我在aks集群的处理方式
spec:
type: LoadBalancer
externalTrafficPolicy: Local
这样做最好在自已整体架构上要下点功夫,使其负载均衡