代码之家  ›  专栏  ›  技术社区  ›  Haoyuan Ge

如何删除kube proxy添加的iptables规则?

  •  0
  • Haoyuan Ge  · 技术社区  · 6 年前

    我想手动删除用于调试的iptables规则。 我有几个由kube proxy根据服务创建的规则 nettools :

    # kubectl get endpoints nettools
    NAME       ENDPOINTS            AGE
    nettools   172.16.27.138:7493   1h
    

    及其IPtables规则

    # iptables-save|grep nettools
    -A KUBE-SEP-6DFMUWHMXOYMFWKG -s 172.16.27.138/32 -m comment --comment "default/nettools:web" -j KUBE-MARK-MASQ
    -A KUBE-SEP-6DFMUWHMXOYMFWKG -p tcp -m comment --comment "default/nettools:web" -m tcp -j DNAT --to-destination 172.16.27.138:7493
    -A KUBE-SERVICES -d 10.0.1.2/32 -p tcp -m comment --comment "default/nettools:web cluster IP" -m tcp --dport 7493 -j KUBE-SVC-INDS3KD6I5PFKUWF
    -A KUBE-SVC-INDS3KD6I5PFKUWF -m comment --comment "default/nettools:web" -j KUBE-SEP-6DFMUWHMXOYMFWKG
    

    但是,我不能删除这些规则:

    # iptables -D  KUBE-SVC-INDS3KD6I5PFKUWF -m comment --comment "default/nettools:web" -j KUBE-SEP-6DFMUWHMXOYMFWKG
    iptables v1.4.21: Couldn't load target `KUBE-SEP-6DFMUWHMXOYMFWKG':No such file or directory
    # iptables -D KUBE-SERVICES -d 10.0.1.2/32 -p tcp -m comment --comment "default/nettools:web cluster IP" -m tcp --dport 7493 -j KUBE-SVC-INDS3KD6I5PFKUWF
    iptables v1.4.21: Couldn't load target `KUBE-SVC-INDS3KD6I5PFKUWF':No such file or directory
    
    1 回复  |  直到 6 年前
        1
  •  2
  •   leodotcloud    6 年前

    处理时有多张桌子在玩 iptables . filter 如果未指定任何内容,则默认使用表。您试图删除的规则是 nat 表。

    只要添加 -t nat 删除这些规则。

    例子:

    # iptables -t nat -D KUBE-SVC-INDS3KD6I5PFKUWF -m comment --comment "default/nettools:web" -j KUBE-SEP-6DFMUWHMXOYMFWKG
    
    推荐文章