You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
containerd: investigate use of firewalld rather than iptables #5136
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?
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.
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 howiptables 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.
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.
@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.
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
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.
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.
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.
Activity
vito commentedon Jun 8, 2020
We can probably close #3127 once this is done.
xtreme-sameer-vohra commentedon Jun 16, 2020
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
firewalldas withiptablesas they both use thenetfilterframework and weren't able to find any docs that explicitly confirmed the issue would be solved by switchingFrom source
Does anyone have more insight into this ? We haven't looked at the internals of
firewalldto see how it leveragesnetfilter.vito commentedon Jun 17, 2020
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 oredit: #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 howiptables. Until we can confirm that it's a deeper underlying kernel issue, I would assume the problem lies iniptables- 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.iptablesinteracts with Netfilter, which may differ from things likenftablesNowadays
nftableshas been introduced to replaceiptables:These benefits sound ideal for our use case of changing rules frequently at runtime, potentially per-container.
It looks like
firewalldgained support for using anftablesbackend instead ofiptablesback in 2018: https://firewalld.org/2018/07/nftables-backendI suppose one argument in favor of
firewalldis that it provides a higher level interface that we can stick to without having to e.g. switch fromiptablestonftables. I'm not really sure how widely availablefirewalldis 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
nftablesis 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 anftablesGo package too.xtreme-sameer-vohra commentedon Jun 17, 2020
Nice, will checkout
nftables. Although, the CNI Network Reference Firewall Plugin only has support foriptablesorfirewalld.Based on my understanding,
firewalldis not available forubuntuand we'd have to bundle it.vito commentedon Jun 17, 2020
@xtreme-sameer-vohra Hmm, yeah that's interesting. I wonder if their intent is to support
nftablesexclusively throughfirewalld?Ubuntu has a
firewalldpackage 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:
Could be problematic for our support of allow/deny networks.
vito commentedon Jun 17, 2020
@xtreme-sameer-vohra @muntac This post might be helpful! https://tomdnetto.net/post/advanced_nftables_with_go
xtreme-sameer-vohra commentedon Jun 19, 2020
As of July 2018 firewalld v0.6.0,
nftablesis the default backend replacing set ofiptables & 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 & familyset of tools were moved under legacy andnftablesis used Source.Next Steps
Denyxtreme-sameer-vohra commentedon Jun 19, 2020
Looks like someone tried adding a
nftablesCNI plugin although the commits have stopped.xtreme-sameer-vohra commentedon Jun 19, 2020
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.
vito commentedon Jun 22, 2020
@xtreme-sameer-vohra Sounds good!
sfuerte commentedon Dec 20, 2022
Are there any plans to add
nftablessupport 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:
containerdworks fine withnftablesnowadays: have a set of instances running Docker /containerdon them; all of those arenftbased, and while Docker dependency list getsiptablesinstalled but overall it works as expected.taylorsilva commentedon Jan 6, 2025
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