Skip to content

Commit bf039b9

Browse files
authored
Support nftables in Node's host network for AntreaProxy (#7545)
Signed-off-by: Hongliang Liu <[email protected]>
1 parent e2eb6aa commit bf039b9

File tree

25 files changed

+1500
-246
lines changed

25 files changed

+1500
-246
lines changed

.github/workflows/kind.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ jobs:
468468
retention-days: 30
469469

470470
test-e2e-hybrid-non-default:
471-
name: E2e tests on a Kind cluster on Linux (hybrid) with non default values (proxyAll=true)
471+
name: E2e tests on a Kind cluster on Linux (hybrid) with non default values (proxyAll=true, kube-proxy-mode=nftables)
472472
needs: [ build-antrea-coverage-image ]
473473
runs-on: [ ubuntu-latest ]
474474
steps:
@@ -504,6 +504,9 @@ jobs:
504504
--encap-mode hybrid \
505505
--coverage \
506506
--proxy-all \
507+
--host-network-mode nftables \
508+
--kube-proxy-mode nftables \
509+
--feature-gates NFTablesHostNetworkMode=true \
507510
--skip mode-irrelevant
508511
- name: Tar coverage files
509512
run: tar -czf test-e2e-hybrid-non-default-coverage.tar.gz test-e2e-hybrid-non-default-coverage

build/charts/antrea/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Kubernetes: `>= 1.23.0-0`
105105
| fqdnCacheMinTTL | int | `0` | fqdnCacheMinTTL helps address the issue of applications caching DNS response IPs beyond the TTL value for the DNS record. It is used to enforce FQDN policy rules, ensuring that resolved IPs are included in datapath rules for as long as the application caches them. Ideally, this value should be set to the maximum caching duration across all applications. |
106106
| hostGateway | string | `"antrea-gw0"` | Name of the interface antrea-agent will create and use for host <-> Pod communication. |
107107
| hostNetworkAcceleration.enable | bool | `true` | Enable to accelerate Pod-to-Pod traffic in the Node's host network using nftables flowtable when traffic mode is noEncap or hybrid. |
108+
| hostNetworkMode | string | `"iptables"` | Determines how antrea-agent implements Node host network netfilter rules required by functionalities and features, using either "iptables" or "nftables". The default value is "iptables". If "nftables" is specified, the NFTablesHostNetworkMode feature gate must be enabled; otherwise, antrea-agent will fail to start. Currently, nftables support is limited to the following features: - AntreaProxy (proxyAll) |
108109
| image | object | `{}` | Container image to use for Antrea components. DEPRECATED: use agentImage and controllerImage instead. |
109110
| ipsec.authenticationMode | string | `"psk"` | The authentication mode to use for IPsec. Must be one of "psk" or "cert". |
110111
| ipsec.csrSigner.autoApprove | bool | `true` | Enable auto approval of Antrea signer for IPsec certificates. |

build/charts/antrea/conf/antrea-agent.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ featureGates:
8383
# remote BGP peers.
8484
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "BGPPolicy" "default" false) }}
8585

86+
# Enable Antrea to use nftables instead of iptables to enforce netfilter rules in the Node's host network for the
87+
# functionalities and features that rely on netfilter. Currently, nftables support is limited to the following features:
88+
# - AntreaProxy (proxyAll)
89+
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "NFTablesHostNetworkMode" "default" false) }}
90+
8691
# Name of the OpenVSwitch bridge antrea-agent will create and use.
8792
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
8893
ovsBridge: {{ .Values.ovs.bridgeName | quote }}
@@ -496,3 +501,11 @@ hostNetworkAcceleration:
496501
# noEncap or hybrid.
497502
enable: {{ .enable }}
498503
{{- end }}
504+
505+
# HostNetworkMode determines how antrea-agent implements Node host network netfilter rules required by Antrea
506+
# functionalities and features, using either "iptables" or "nftables". The default value is "iptables". If "nftables"
507+
# is specified, the NFTablesHostNetworkMode feature gate must be enabled; otherwise, antrea-agent will fail to start.
508+
# If the above condition is met but nftables is not supported or unavailable on the Node, antrea-agent will also fail
509+
# to start. Currently, nftables support is limited to the following features:
510+
# - AntreaProxy (proxyAll)
511+
hostNetworkMode: {{ .Values.hostNetworkMode | quote }}

build/charts/antrea/values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,3 +489,10 @@ hostNetworkAcceleration:
489489
# -- Enable to accelerate Pod-to-Pod traffic in the Node's host network using nftables flowtable when traffic mode is
490490
# noEncap or hybrid.
491491
enable: true
492+
493+
# -- Determines how antrea-agent implements Node host network netfilter rules required by functionalities and features,
494+
# using either "iptables" or "nftables". The default value is "iptables". If "nftables" is specified, the
495+
# NFTablesHostNetworkMode feature gate must be enabled; otherwise, antrea-agent will fail to start. Currently, nftables
496+
# support is limited to the following features:
497+
# - AntreaProxy (proxyAll)
498+
hostNetworkMode: "iptables"

build/yamls/antrea-aks.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4296,6 +4296,11 @@ data:
42964296
# remote BGP peers.
42974297
# BGPPolicy: false
42984298
4299+
# Enable Antrea to use nftables instead of iptables to enforce netfilter rules in the Node's host network for the
4300+
# functionalities and features that rely on netfilter. Currently, nftables support is limited to the following features:
4301+
# - AntreaProxy (proxyAll)
4302+
# NFTablesHostNetworkMode: false
4303+
42994304
# Name of the OpenVSwitch bridge antrea-agent will create and use.
43004305
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
43014306
ovsBridge: "br-int"
@@ -4661,6 +4666,14 @@ data:
46614666
# Enable to accelerate Pod-to-Pod traffic in the Node's host network using nftables flowtable when traffic mode is
46624667
# noEncap or hybrid.
46634668
enable: true
4669+
4670+
# HostNetworkMode determines how antrea-agent implements Node host network netfilter rules required by Antrea
4671+
# functionalities and features, using either "iptables" or "nftables". The default value is "iptables". If "nftables"
4672+
# is specified, the NFTablesHostNetworkMode feature gate must be enabled; otherwise, antrea-agent will fail to start.
4673+
# If the above condition is met but nftables is not supported or unavailable on the Node, antrea-agent will also fail
4674+
# to start. Currently, nftables support is limited to the following features:
4675+
# - AntreaProxy (proxyAll)
4676+
hostNetworkMode: "iptables"
46644677
antrea-cni.conflist: |
46654678
{
46664679
"cniVersion":"0.3.0",
@@ -5700,7 +5713,7 @@ spec:
57005713
kubectl.kubernetes.io/default-container: antrea-agent
57015714
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
57025715
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5703-
checksum/config: 3102c632b42c98e161207364e65fa751a0b0831e87d878a3242c013c1b7d3c2b
5716+
checksum/config: 288c5f3c4ff78c08520f7ddd0ba8547774d0fe9724ed649e32fa6e4f5ab6830c
57045717
labels:
57055718
app: antrea
57065719
component: antrea-agent
@@ -5948,7 +5961,7 @@ spec:
59485961
annotations:
59495962
# Automatically restart Pod if the ConfigMap changes
59505963
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5951-
checksum/config: 3102c632b42c98e161207364e65fa751a0b0831e87d878a3242c013c1b7d3c2b
5964+
checksum/config: 288c5f3c4ff78c08520f7ddd0ba8547774d0fe9724ed649e32fa6e4f5ab6830c
59525965
labels:
59535966
app: antrea
59545967
component: antrea-controller

build/yamls/antrea-eks.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4292,6 +4292,11 @@ data:
42924292
# remote BGP peers.
42934293
# BGPPolicy: false
42944294
4295+
# Enable Antrea to use nftables instead of iptables to enforce netfilter rules in the Node's host network for the
4296+
# functionalities and features that rely on netfilter. Currently, nftables support is limited to the following features:
4297+
# - AntreaProxy (proxyAll)
4298+
# NFTablesHostNetworkMode: false
4299+
42954300
# Name of the OpenVSwitch bridge antrea-agent will create and use.
42964301
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
42974302
ovsBridge: "br-int"
@@ -4657,6 +4662,14 @@ data:
46574662
# Enable to accelerate Pod-to-Pod traffic in the Node's host network using nftables flowtable when traffic mode is
46584663
# noEncap or hybrid.
46594664
enable: true
4665+
4666+
# HostNetworkMode determines how antrea-agent implements Node host network netfilter rules required by Antrea
4667+
# functionalities and features, using either "iptables" or "nftables". The default value is "iptables". If "nftables"
4668+
# is specified, the NFTablesHostNetworkMode feature gate must be enabled; otherwise, antrea-agent will fail to start.
4669+
# If the above condition is met but nftables is not supported or unavailable on the Node, antrea-agent will also fail
4670+
# to start. Currently, nftables support is limited to the following features:
4671+
# - AntreaProxy (proxyAll)
4672+
hostNetworkMode: "iptables"
46604673
antrea-cni.conflist: |
46614674
{
46624675
"cniVersion":"0.3.0",
@@ -5696,7 +5709,7 @@ spec:
56965709
kubectl.kubernetes.io/default-container: antrea-agent
56975710
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
56985711
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5699-
checksum/config: 3102c632b42c98e161207364e65fa751a0b0831e87d878a3242c013c1b7d3c2b
5712+
checksum/config: 288c5f3c4ff78c08520f7ddd0ba8547774d0fe9724ed649e32fa6e4f5ab6830c
57005713
labels:
57015714
app: antrea
57025715
component: antrea-agent
@@ -5945,7 +5958,7 @@ spec:
59455958
annotations:
59465959
# Automatically restart Pod if the ConfigMap changes
59475960
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5948-
checksum/config: 3102c632b42c98e161207364e65fa751a0b0831e87d878a3242c013c1b7d3c2b
5961+
checksum/config: 288c5f3c4ff78c08520f7ddd0ba8547774d0fe9724ed649e32fa6e4f5ab6830c
59495962
labels:
59505963
app: antrea
59515964
component: antrea-controller

build/yamls/antrea-gke.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4292,6 +4292,11 @@ data:
42924292
# remote BGP peers.
42934293
# BGPPolicy: false
42944294
4295+
# Enable Antrea to use nftables instead of iptables to enforce netfilter rules in the Node's host network for the
4296+
# functionalities and features that rely on netfilter. Currently, nftables support is limited to the following features:
4297+
# - AntreaProxy (proxyAll)
4298+
# NFTablesHostNetworkMode: false
4299+
42954300
# Name of the OpenVSwitch bridge antrea-agent will create and use.
42964301
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
42974302
ovsBridge: "br-int"
@@ -4657,6 +4662,14 @@ data:
46574662
# Enable to accelerate Pod-to-Pod traffic in the Node's host network using nftables flowtable when traffic mode is
46584663
# noEncap or hybrid.
46594664
enable: true
4665+
4666+
# HostNetworkMode determines how antrea-agent implements Node host network netfilter rules required by Antrea
4667+
# functionalities and features, using either "iptables" or "nftables". The default value is "iptables". If "nftables"
4668+
# is specified, the NFTablesHostNetworkMode feature gate must be enabled; otherwise, antrea-agent will fail to start.
4669+
# If the above condition is met but nftables is not supported or unavailable on the Node, antrea-agent will also fail
4670+
# to start. Currently, nftables support is limited to the following features:
4671+
# - AntreaProxy (proxyAll)
4672+
hostNetworkMode: "iptables"
46604673
antrea-cni.conflist: |
46614674
{
46624675
"cniVersion":"0.3.0",
@@ -5687,7 +5700,7 @@ spec:
56875700
kubectl.kubernetes.io/default-container: antrea-agent
56885701
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
56895702
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5690-
checksum/config: cbbcacc8999c945122b022df66a13638197a09dbd45eaa1120c1549c2a43ef3a
5703+
checksum/config: 5e5d2ddcb67315f41931c275be9cb3df79cb82bd82b86390408b9aae2ddc1701
56915704
labels:
56925705
app: antrea
56935706
component: antrea-agent
@@ -5933,7 +5946,7 @@ spec:
59335946
annotations:
59345947
# Automatically restart Pod if the ConfigMap changes
59355948
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5936-
checksum/config: cbbcacc8999c945122b022df66a13638197a09dbd45eaa1120c1549c2a43ef3a
5949+
checksum/config: 5e5d2ddcb67315f41931c275be9cb3df79cb82bd82b86390408b9aae2ddc1701
59375950
labels:
59385951
app: antrea
59395952
component: antrea-controller

build/yamls/antrea-ipsec.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4305,6 +4305,11 @@ data:
43054305
# remote BGP peers.
43064306
# BGPPolicy: false
43074307
4308+
# Enable Antrea to use nftables instead of iptables to enforce netfilter rules in the Node's host network for the
4309+
# functionalities and features that rely on netfilter. Currently, nftables support is limited to the following features:
4310+
# - AntreaProxy (proxyAll)
4311+
# NFTablesHostNetworkMode: false
4312+
43084313
# Name of the OpenVSwitch bridge antrea-agent will create and use.
43094314
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
43104315
ovsBridge: "br-int"
@@ -4670,6 +4675,14 @@ data:
46704675
# Enable to accelerate Pod-to-Pod traffic in the Node's host network using nftables flowtable when traffic mode is
46714676
# noEncap or hybrid.
46724677
enable: true
4678+
4679+
# HostNetworkMode determines how antrea-agent implements Node host network netfilter rules required by Antrea
4680+
# functionalities and features, using either "iptables" or "nftables". The default value is "iptables". If "nftables"
4681+
# is specified, the NFTablesHostNetworkMode feature gate must be enabled; otherwise, antrea-agent will fail to start.
4682+
# If the above condition is met but nftables is not supported or unavailable on the Node, antrea-agent will also fail
4683+
# to start. Currently, nftables support is limited to the following features:
4684+
# - AntreaProxy (proxyAll)
4685+
hostNetworkMode: "iptables"
46734686
antrea-cni.conflist: |
46744687
{
46754688
"cniVersion":"0.3.0",
@@ -5700,7 +5713,7 @@ spec:
57005713
kubectl.kubernetes.io/default-container: antrea-agent
57015714
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
57025715
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5703-
checksum/config: 5ff1f5f4019866e71c486257fd6ad4fb867855ba3c7bd603bfce7c4d77f16116
5716+
checksum/config: 81878499e95213bf2ccdbc6511bf7f61a84126783eda2cff31f21eb8109315e0
57045717
checksum/ipsec-secret: d0eb9c52d0cd4311b6d252a951126bf9bea27ec05590bed8a394f0f792dcb2a4
57055718
labels:
57065719
app: antrea
@@ -5992,7 +6005,7 @@ spec:
59926005
annotations:
59936006
# Automatically restart Pod if the ConfigMap changes
59946007
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5995-
checksum/config: 5ff1f5f4019866e71c486257fd6ad4fb867855ba3c7bd603bfce7c4d77f16116
6008+
checksum/config: 81878499e95213bf2ccdbc6511bf7f61a84126783eda2cff31f21eb8109315e0
59966009
labels:
59976010
app: antrea
59986011
component: antrea-controller

build/yamls/antrea.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4292,6 +4292,11 @@ data:
42924292
# remote BGP peers.
42934293
# BGPPolicy: false
42944294
4295+
# Enable Antrea to use nftables instead of iptables to enforce netfilter rules in the Node's host network for the
4296+
# functionalities and features that rely on netfilter. Currently, nftables support is limited to the following features:
4297+
# - AntreaProxy (proxyAll)
4298+
# NFTablesHostNetworkMode: false
4299+
42954300
# Name of the OpenVSwitch bridge antrea-agent will create and use.
42964301
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
42974302
ovsBridge: "br-int"
@@ -4657,6 +4662,14 @@ data:
46574662
# Enable to accelerate Pod-to-Pod traffic in the Node's host network using nftables flowtable when traffic mode is
46584663
# noEncap or hybrid.
46594664
enable: true
4665+
4666+
# HostNetworkMode determines how antrea-agent implements Node host network netfilter rules required by Antrea
4667+
# functionalities and features, using either "iptables" or "nftables". The default value is "iptables". If "nftables"
4668+
# is specified, the NFTablesHostNetworkMode feature gate must be enabled; otherwise, antrea-agent will fail to start.
4669+
# If the above condition is met but nftables is not supported or unavailable on the Node, antrea-agent will also fail
4670+
# to start. Currently, nftables support is limited to the following features:
4671+
# - AntreaProxy (proxyAll)
4672+
hostNetworkMode: "iptables"
46604673
antrea-cni.conflist: |
46614674
{
46624675
"cniVersion":"0.3.0",
@@ -5687,7 +5700,7 @@ spec:
56875700
kubectl.kubernetes.io/default-container: antrea-agent
56885701
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
56895702
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5690-
checksum/config: 5e83f654fbb48b39b21ceeeb20d4d60ca1cf3de258acc258a2cc961eda9ac2a2
5703+
checksum/config: 4cddc6760e67614e8a0fd94cb2f88148342bff967dcaf74a4053ea424ea0d853
56915704
labels:
56925705
app: antrea
56935706
component: antrea-agent
@@ -5933,7 +5946,7 @@ spec:
59335946
annotations:
59345947
# Automatically restart Pod if the ConfigMap changes
59355948
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5936-
checksum/config: 5e83f654fbb48b39b21ceeeb20d4d60ca1cf3de258acc258a2cc961eda9ac2a2
5949+
checksum/config: 4cddc6760e67614e8a0fd94cb2f88148342bff967dcaf74a4053ea424ea0d853
59375950
labels:
59385951
app: antrea
59395952
component: antrea-controller

ci/kind/kind-setup.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ where:
6161
--service-cidr: specify service clusterip cidr used in kind cluster, kind's default value will be used if empty.
6262
--encap-mode: inter-node pod traffic encap mode, default is encap.
6363
--no-proxy: disable Antrea proxy.
64-
--no-kube-proxy: disable Kube proxy.
64+
--no-kube-proxy: deprecated. This option is still supported for compatibility, but will be removed. Use '--kube-proxy-mode none' going forward to disable kube-proxy.
65+
--kube-proxy-mode: specify the kube-proxy mode. Supported values are 'iptables', 'nftables', 'ipvs' and 'none' (to disable kube-proxy).
6566
--no-kube-node-ipam: disable NodeIPAM in kube-controller-manager.
6667
--antrea-cni: install Antrea CNI in Kind cluster; by default the cluster is created without a CNI installed.
6768
--prometheus: create RBAC resources for Prometheus, default is false.
@@ -719,10 +720,16 @@ while [[ $# -gt 0 ]]
719720
shift
720721
;;
721722
--no-kube-proxy)
723+
echo "WARNING: '--no-kube-proxy' is deprecated. Use '--kube-proxy-mode none' instead."
722724
add_option "--no-kube-proxy" "create"
723725
KUBE_PROXY_MODE="none"
724726
shift
725727
;;
728+
--kube-proxy-mode)
729+
add_option "--kube-proxy-mode" "create"
730+
KUBE_PROXY_MODE="$2"
731+
shift 2
732+
;;
726733
--no-kube-node-ipam)
727734
add_option "--no-kube-node-ipam" "create"
728735
KUBE_NODE_IPAM=false

0 commit comments

Comments
 (0)