-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support applying ClusterNetworkPolicy to Nodes in Antrea #5671
Comments
Dataplane PRs:
|
@hongliangl I suppose there is a PR implementing the |
@tnqn Thank you for bringing some attention to this. I like your proposal and it looks like it would cover all the use cases I had from my original issue. Well done 👍 |
Please look at this PR #5658 |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment, or this will be closed in 90 days |
Describe what you are trying to solve
#4213 asked for the ability to apply NetworkPolicies to not only Pods but also Kubernetes Nodes. Antrea currently has a feature called ExternalNode, which enables users to apply NetworkPolicies for non-Kubernetes Nodes. The two requirements are kind of the same thing from a technical perspective.
The implementation of ExternalNode moves the primary network interfaces of Nodes to OVS bridge and uses OpenFlow flows to enforce policies, which met great chanllenges in compatibility with OSes, especially when DHCP is used and on cloud platforms. #5192 and #5221 are two examples.
This proposal describes a simple and steady way to apply NetworkPolicies to Kubernetes Nodes, which can also be used by ExternalNode in the future, unifying the implementation and resolving the known problems.
Describe the solution you have in mind
Dataplane
There could be four technical approaches to apply NetworkPolicies to Nodes:
2. Effcient
2. Hard to be compaible with various network device managers
2. More efforts to implement firewall from scratch: including priority-based packet classier, connection tracking
2. Complex datapath
3. Uncertain side effect
2. Easy to support multiple interfaces
All things considered, iptables/netfilter seems the most practicable approach if its performance disadvantage doesn't cause a problem in this use case. Then let's look at how it behaves with different numbers of rules. I have ran benchmark using iperf and netperf with different number rules in iptables filter table and here are the numbers:
As seen from the numbers, throughput (by Bitrate) and latency (by TCP_RR) are almost unaffected by the number of rules, which meets the expectation as the number of rules only affects the first packet of a connection in most cases. TCP_CRR became worse while number of rules increased. It decreased 9.09% with 50 rules and 13.6% with 100 rules. But considering the use case and the expectation that one NetworkPolicy rule will be mapped to an iptables rule regardless of the number of IPs used by it (thanks to ipset), it's unlikely that the number of rules applied to a single Node could exceed 100 and perhaps could be less as users will likely just deny all and only allow specific accesses on the principle of least privilege.
So we propose to use iptables/netfilter in dataplane.
API Change
Considring Node is a cluster scope resource, and the current API types in Antrea, we will make the following API changes:
AppliedTo
can useNodeSelector
, which means the policy/rule is applied to Nodes, instead of Pods.AppliedTo
can't useNodeSelector
and other selectors together to simplify the implementation.An example of a ClusterNetworkPolicy applied to Nodes, it allows all Nodes in this cluster and clients whose IP are in 10.0.0.0/24 can access control-plane Nodes's TCP 6443 port, and drops all other accesses to these Nodes.
Configuration Change
NodeNetworkPolicy
will control the enablement of the feature.Workflow
Interfaces
In antrea-agent, we will reuse the
Reconciler
interface, and create a new implementation, which programs iptables and ipset to enforce the given rules.In
Controller.syncRule
, we will call NodeRuleReconciler instead of the existing reconciler to realize a rule if it applies to Nodes:Plan
The text was updated successfully, but these errors were encountered: