Skip to content

nftables do not scale for services #96018

Closed

Description

@mskrocki

What happened:
Can only scale up to ~500 services on a nftables based cluster (CentOS 8+, Debian 10+) with kube-proxy.
With 1000 services, around half fails to work.

What you expected to happen:
Tested with same cluster deployment, but on Ubuntu 18.04 (that uses legacy iptables) and managed to reach 2500 services.

How to reproduce it (as minimally and precisely as possible):

  • create a 100 node cluster on OS with nftables enabled (CentOS 8, Debian 10)
  • create simple http deployment (nginx) with 200 replicas
  • create Load Balancer services (below example): I have used 100 VIPs and 10 Ports/svc
  • wait for the cluster to "stabilize"
  • try curl to every svcIP:Port
apiVersion: v1
kind: Service
metadata:
  name: scale-service-{{.Num}}
spec:
  ports:
{{range .Ports}}
  - port: {{.}}
    protocol: TCP
    targetPort: 8080
    name: sv{{.}}
{{- end}}
  selector:
    app: scale-service
  sessionAffinity: None
  type: LoadBalancer
  loadBalancerIP: {{.IP}}

Anything else we need to know?:
The iptables-save rules count on nftables reached ~400k lines when some services were unreachable.
For the non-nftables case I was able to see >1m rules.

Environment:

  • Kubernetes version (use kubectl version): 1.18.6
  • Cloud provider or hardware configuration: Deployed on VMs with 4vCPU, 16G mem, 50G disk,
  • OS (e.g: cat /etc/os-release): CentOS 8.1
  • Kernel (e.g. uname -a): 4.18
  • Install tools: kubeadm
  • Network plugin and version (if this is a network-related bug): Cilium 1.8 with kube-proxy present, using metalLB
  • Others:

Activity

  1. added
    kind/bugCategorizes issue or PR as related to a bug.
    on Oct 29, 2020
  2. added
    needs-sigIndicates an issue or PR lacks a `sig/foo` label and requires one.
    on Oct 29, 2020
  3. k8s-ci-robot commented on Oct 29, 2020

    @k8s-ci-robot
    Contributor

    @mskrocki: This issue is currently awaiting triage.

    If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

    The triage/accepted label can be added by org members by writing /triage accepted in a comment.

    Details

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

  4. added
    needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.
    on Oct 29, 2020
  5. mskrocki commented on Oct 29, 2020

    @mskrocki
    ContributorAuthor

    /sig network

  6. added
    sig/networkCategorizes an issue or PR as relevant to SIG Network.
    and removed
    needs-sigIndicates an issue or PR lacks a `sig/foo` label and requires one.
    on Oct 29, 2020
  7. bridgetkromhout commented on Oct 29, 2020

    @bridgetkromhout
    Member

    Discussion of newer OS version. (At least 1.8.4 of iptables)
    /assign @dcbw

  8. mskrocki commented on Nov 4, 2020

    @mskrocki
    ContributorAuthor

    I see same results (only ~500 services) on:

    # cat /etc/redhat-release
    CentOS Linux release 8.2.2004 (Core)
    
    # iptables --version
    iptables v1.8.4 (nf_tables)
    
  9. bowei commented on Nov 6, 2020

    @bowei
    Member

    /assign

  10. dcbw commented on Nov 12, 2020

    @dcbw
    Contributor

    @mskrocki what specific RPM version of iptables? I would recommend iptables-1.8.4-10.el8_2.2

  11. dcbw commented on Nov 12, 2020

    @dcbw
    Contributor

    And if you have a relatively recent iptables, when you have 1000 services, could you grab iptables-save dump and attach?

  12. mskrocki commented on Nov 13, 2020

    @mskrocki
    ContributorAuthor

    I have been using 1.8.4-10.el8_2.1, any guide on how I can get the 2.2 version?
    I will try the test again and provide the dump later.

  13. 12 remaining items

  14. dcbw commented on Feb 19, 2021

    @dcbw
    Contributor

    So... this iptables save is 695992 lines. Which is extremely large. In the past, with just iptables (eg not iptables-nft), I've seen performance issues with iptables-restore with just 100,000 or 150,000 lines. We typically recommend setting min-sync-period to some large number of seconds (30? 60?) in cases like that.

    Are you able to find out how much time iptables-restore (nft) takes to restore this 700,000 line dump?

  15. mskrocki commented on Feb 19, 2021

    @mskrocki
    ContributorAuthor

    Run directly on the host:

    # time iptables-restore iptables2.log 
    iptables-restore: line 695918 failed
    
    real    0m12.772s
    user    0m10.062s
    sys     0m2.450s
    
  16. dcbw commented on Mar 4, 2021

    @dcbw
    Contributor

    @mskrocki would you be able to provide that iptables-restore ruleset for further analysis?

  17. dcbw commented on Mar 18, 2021

    @dcbw
    Contributor

    @mskrocki ping? If we can get a ruleset from iptables-restore we can figure out where the hotspots are.

  18. mskrocki commented on Mar 18, 2021

    @mskrocki
    ContributorAuthor

    I dont have that one exactly. What about the one I linked above, I dont think it will be any different.

  19. n0-1 commented on Mar 24, 2021

    @n0-1

    Hi,

    I can reproduce the failure with upstream iptables.
    As for run-time, iptables-legacy restores the attached dump in 6.5min on my testing VM, iptables-nft fails after 16min. :(
    Maybe the ruleset is simply too big, but of course if legacy iptables eats it iptables-nft shall do as well.
    Still investigating, just a quick status update.

    Cheers, Phil

  20. dougsland commented on Mar 26, 2021

    @dougsland
    Contributor

    /area kube-proxy

  21. dcbw commented on Apr 6, 2021

    @dcbw
    Contributor

    Phil and Pablo have posted patches to improve iptables-nft performance to iptables-legacy levels based on the ruleset from this issue:
    https://marc.info/?l=netfilter-devel&m=161730110620551&w=2
    https://marc.info/?l=netfilter-devel&m=161730896024892&w=2

  22. n0-1 commented on Apr 6, 2021

    @n0-1

    A fix to allow for large rulesets currently under review: https://marc.info/?l=netfilter-devel&m=161769909013299&w=2
    Performance improvement applied meanwhile: https://marc.info/?l=netfilter-devel&m=161676942405027&w=2

  23. dcbw commented on Apr 15, 2021

    @dcbw
    Contributor

    While I think it was good to keep this bug open to debug/track the problem, I think we can close it now since the fixes are in nftables/iptables and are under review or already merged.
    /close

  24. k8s-ci-robot commented on Apr 15, 2021

    @k8s-ci-robot
    Contributor

    @dcbw: Closing this issue.

    Details

    In response to this:

    While I think it was good to keep this bug open to debug/track the problem, I think we can close it now since the fixes are in nftables/iptables and are under review or already merged.
    /close

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

  25. liuyuan10 commented on Jul 20, 2022

    @liuyuan10

    @n0-1 @dcbw Thanks for fixing it. could you provide the version of iptables that has all the fix we talked about here?

  26. n0-1 commented on Jul 23, 2022

    @n0-1

    @liuyuan10 iptables v1.8.8 has all you need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/kube-proxykind/bugCategorizes issue or PR as related to a bug.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.sig/networkCategorizes an issue or PR as relevant to SIG Network.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions