Skip to content

containerd: investigate use of firewalld rather than iptables #5136

Closed as not planned

Description

@cirocosta

what challange are you facing

we have a hypotheesis that iptables can be quite resource intensive when the
number of containers get high (or the number of operations on it is large),
leading to problems like describe in #3694.

in the current networking implementation set up for containerd, we're defaulting
to use iptables, and that works fine, it might be that with firewalld (a
backend supported by the firewall CNI plugin) we achieve even better
performance (given that it can operate on rule diffs rather than having to
perform flushes for each change).

what would make this better

be able to decide how we want to go with regards to the component that deals
with networking: iptables? firewalld?

references:

Activity

  1. deleted a comment from stale on Jun 8, 2020
  2. vito commented on Jun 8, 2020

    @vito
    Contributor

    We can probably close #3127 once this is done.

  3. xtreme-sameer-vohra commented on Jun 16, 2020

    @xtreme-sameer-vohra
    Contributor

    Hey folks,
    @muntac and I were looked at this briefly while working on #5534. Given #3127 , we found a source that seemed to imply that we might experience the same issue with firewalld as with iptables as they both use the netfilter framework and weren't able to find any docs that explicitly confirmed the issue would be solved by switching

    From source

    Under the hood, both firewalld and the iptables service talk to the netfilter framework in the kernel through the same interface, not surprisingly, the iptables command. However, as opposed to the iptables service, firewalld can change the settings during normal system operation without existing connections being lost. 
    

    Does anyone have more insight into this ? We haven't looked at the internals of firewalld to see how it leverages netfilter.

  4. vito commented on Jun 17, 2020

    @vito
    Contributor

    I don't think we can really assume anything about the underlying use of Netfilter with regard to #3127. Netfilter is an underlying kernel primitive that just about every networking system uses. We don't know if the error came from Netfilter or iptables. Until we can confirm that it's a deeper underlying kernel issue, I would assume the problem lies in iptables - Google results indicate there are many different ways to run into the same error, e.g. when there are either too many rules or too many open connections. edit: #3127 (comment) indicates that at least one case was an underlying issue with Netfilter code in the kernel - though even so, this may be particular to how iptables interacts with Netfilter, which may differ from things like nftables

    Nowadays nftables has been introduced to replace iptables:

    The main advantages over iptables are simplification of the Linux kernel ABI, reduction of code duplication, improved error reporting, and more efficient execution, storage, and incremental, atomic changes of filtering rules.

    These benefits sound ideal for our use case of changing rules frequently at runtime, potentially per-container.

    It looks like firewalld gained support for using a nftables backend instead of iptables back in 2018: https://firewalld.org/2018/07/nftables-backend

    I suppose one argument in favor of firewalld is that it provides a higher level interface that we can stick to without having to e.g. switch from iptables to nftables. I'm not really sure how widely available firewalld is though. That may be something to investigate. It looks like it's not installed in Ubuntu by default.

    We should at least be able to assume that nftables is available - it was introduced in Linux 3.13, and our minimum requirement is 3.19. Both of these are actually super old by now, so it should be pretty widely available. Looks like Google is working on a nftables Go package too.

  5. xtreme-sameer-vohra commented on Jun 17, 2020

    @xtreme-sameer-vohra
    Contributor

    Nice, will checkout nftables. Although, the CNI Network Reference Firewall Plugin only has support for iptables or firewalld.

    Based on my understanding, firewalld is not available for ubuntu and we'd have to bundle it.

  6. vito commented on Jun 17, 2020

    @vito
    Contributor

    @xtreme-sameer-vohra Hmm, yeah that's interesting. I wonder if their intent is to support nftables exclusively through firewalld?

    Ubuntu has a firewalld package and a few other popular distros have it by default, so it might be OK to just list it as a prerequisite. Extra steps can be annoying though and it may be complicated to package. (It might also be complicated to interact with in K8s. 🤔)

    This may also be something to investigate:

    Limitations:

    Firewalld currently does not support outbound rules to the same capacity of inbound rules. Limitations include things such on ipsets, service names, and default outbound block by default rules required by standards such as NIST 800-171 and 800-53. Default block all needs to be done at the "raw" IPTables level via the --direct flag, and with the order of operations FirewallD uses to prioritize Rrules, rich rules, direct rules, it may be easier to enter all rules for outbound via --direct or use iptables (netfilter-persist)

    Could be problematic for our support of allow/deny networks.

  7. vito commented on Jun 17, 2020

    @vito
    Contributor
  8. xtreme-sameer-vohra commented on Jun 19, 2020

    @xtreme-sameer-vohra
    Contributor

    As of July 2018 firewalld v0.6.0, nftables is the default backend replacing set of iptables & family.

    We are running 1.6 of iptables in our docker image (v5.8) and on BOSH (ubuntu xenial v456.27).

    As of June 2018 (v1.8.x of iptables), the iptables & family set of tools were moved under legacy and nftables is used Source.

    Next Steps

    • Can we switch to nftables with CNI using either firewalld or iptables ? Since nftables introduces concept of namespaces, we would be able to create our own namespace to specify our own rules such as Deny
  9. xtreme-sameer-vohra commented on Jun 19, 2020

    @xtreme-sameer-vohra
    Contributor

    As of July 2018 firewalld v0.6.0, nftables is the default backend replacing set of iptables & family.

    We are running 1.6 of iptables in our docker image (v5.8) and on BOSH (ubuntu xenial v456.27).

    As of June 2018 (v1.8.x of iptables), the iptables & family set of tools were moved under legacy and nftables is used Source.

    Next Steps

    • Can we switch to nftables with CNI using either firewalld or iptables ? Since nftables introduces concept of namespaces, we would be able to create our own namespace to specify our own rules such as Deny

    Looks like someone tried adding a nftables CNI plugin although the commits have stopped.

  10. xtreme-sameer-vohra commented on Jun 19, 2020

    @xtreme-sameer-vohra
    Contributor

    I think there is enough investigative work for this issue to remain a standalone issue and not linked to #5534 . To not block #5534 I am leaning towards moving ahead with Iptables and we will revisit the decision when we tackle this story. IMHO re-work won't be substantial as compared to blocking #5534 and tackling this issue first.

  11. vito commented on Jun 22, 2020

    @vito
    Contributor
  12. sfuerte commented on Dec 20, 2022

    @sfuerte

    Are there any plans to add nftables support for Concourse Workers any time soon?

    It works just fine for the Web instances but looks like a Worker does a CLI command under the hood and fails with the following:

    {"timestamp":"2022-12-20T18:35:52.029335381Z", "level":"error", "source":"worker", "message":"worker.garden.garden-server.create.failed", "data":{"error":"starting task: network add: cni net setup: plugin type="firewall" failed (add): failed to list iptables chains: running [/usr/sbin/iptables -t filter -S --wait]: exit status 1: iptables v1.8.7 (nf_tables): table `filter' is incompatible, use 'nft' tool.

    containerd works fine with nftables nowadays: have a set of instances running Docker / containerd on them; all of those are nft based, and while Docker dependency list gets iptables installed but overall it works as expected.

  13. taylorsilva commented on Jan 6, 2025

    @taylorsilva
    Member

    Issue Bankruptcy

    This issue is being closed as part of 2025's Issue Bankruptcy declaration. See here for details

    If you think this issue still has merit then feel free to open a new issue and reference this one.


    Kept parent issue around which references this one

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions