V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Recommended Services
Amazon Web Services
LeanCloud
New Relic
ClearDB
kidlj
V2EX  ›  云计算

kube-proxy IPVS 模式的一个疑问

  •  
  •   kidlj · 2018-11-21 22:18:14 +08:00 · 2083 次点击
    这是一个创建于 1954 天前的主题,其中的信息可能已经有所发展或是发生改变。

    经过仔细研究发现,kube-proxy 开启了 IPVS 模式的情况下:

    1. 访问 service 的入流量,iptables 只是 mark 封包就完成了,后面交给了 IPVS 来做 DNAT。

    2. 由 endpoint 到 service 的出流量,iptables mark 封包以后又做了 MASQUERADE 的工作;这一步的工作为什么不能交由 IPVS 直接完成?

    Chain KUBE-POSTROUTING (1 references)
    target     prot opt source               destination
    MASQUERADE  all  --  0.0.0.0/0            0.0.0.0/0            /* kubernetes service traffic requiring SNAT */ mark match 0x4000/0x4000
    MASQUERADE  all  --  0.0.0.0/0            0.0.0.0/0            match-set KUBE-LOOP-BACK dst,dst,src
    

    另外请问,IPVS 模式的代理性能是否要比 iptables 好很多,是否还有必要自研四层负载均衡( Ingress Controller )呢?

    2 条回复    2018-11-22 12:43:40 +08:00
    abmin521
        1
    abmin521  
       2018-11-22 12:07:55 +08:00 via Android
    第一个应该是 负载均衡用的

    第二个 随意啦
    kidlj
        2
    kidlj  
    OP
       2018-11-22 12:43:40 +08:00
    在 Kubernetes mailinglist 上发问,得到了下面的回复,感觉理解了。

    > It is not iptables doing *NAT/MASQUERADE, it is netfilter.
    iptables is just an interface to netfilter just like ipvs. So fall
    back here means ipvs does not setup *NAT rules for netfilter, it just
    call iptables to setup the rules.

    另外参考了华为做的 IPVS 和 iptables mode 的性能基准测试,IPVS 模式的性能会好很多,因为免除了大量 iptables rules 的增减,只使用了固定几条 iptables 规则。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   981 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 20:18 · PVG 04:18 · LAX 13:18 · JFK 16:18
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.