成功最有效的方法就是向有经验的人学习!

LoadBalancer对外暴露服务时程序无法获取用户真实IP

之前我们一直使用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).

file

调整方式

#我在aks集群的处理方式
spec:
  type: LoadBalancer
  externalTrafficPolicy: Local

这样做最好在自已整体架构上要下点功夫,使其负载均衡

赞(2) 打赏
未经允许不得转载:陈桂林博客 » LoadBalancer对外暴露服务时程序无法获取用户真实IP
分享到

大佬们的评论 抢沙发

全新“一站式”建站,高质量、高售后的一条龙服务

微信 抖音 支付宝 百度 头条 快手全平台打通信息流

橙子建站.极速智能建站8折购买虚拟主机

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册