Skip to content

Commit bf07ef3

Browse files
authored
Merge pull request kubernetes#124383 from danwinship/nftables-proxy-to-beta
KEP-3866 kube-proxy nftables to beta
2 parents fd40d68 + 9f580af commit bf07ef3

File tree

4 files changed

+32
-20
lines changed

4 files changed

+32
-20
lines changed

cluster/gce/config-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ KUBE_PROXY_DAEMONSET=${KUBE_PROXY_DAEMONSET:-false} # true, false
532532
# as an addon daemonset.
533533
KUBE_PROXY_DISABLE="${KUBE_PROXY_DISABLE:-false}" # true, false
534534

535-
# Optional: Change the kube-proxy implementation. Choices are [iptables, ipvs].
535+
# Optional: Change the kube-proxy implementation. Choices are [iptables, ipvs, nftables].
536536
KUBE_PROXY_MODE=${KUBE_PROXY_MODE:-iptables}
537537

538538
# Will be passed into the kube-proxy via `--detect-local-mode`

cluster/gce/gci/configure-helper.sh

100644100755
Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,24 +1753,35 @@ function prepare-kube-proxy-manifest-variables {
17531753
if [[ -n "${FEATURE_GATES:-}" ]]; then
17541754
params+=" --feature-gates=${FEATURE_GATES}"
17551755
fi
1756-
if [[ "${KUBE_PROXY_MODE:-}" == "ipvs" ]];then
1757-
# use 'nf_conntrack' instead of 'nf_conntrack_ipv4' for linux kernel >= 4.19
1758-
# https://github.com/kubernetes/kubernetes/pull/70398
1759-
local -r kernel_version=$(uname -r | cut -d\. -f1,2)
1760-
local conntrack_module="nf_conntrack"
1761-
if [[ $(printf '%s\n4.18\n' "${kernel_version}" | sort -V | tail -1) == "4.18" ]]; then
1762-
conntrack_module="nf_conntrack_ipv4"
1763-
fi
17641756

1765-
if sudo modprobe -a ip_vs ip_vs_rr ip_vs_wrr ip_vs_sh ${conntrack_module}; then
1766-
params+=" --proxy-mode=ipvs"
1767-
else
1768-
# If IPVS modules are not present, make sure the node does not come up as
1769-
# healthy.
1770-
exit 1
1771-
fi
1772-
fi
1773-
params+=" --iptables-sync-period=1m --iptables-min-sync-period=10s --ipvs-sync-period=1m --ipvs-min-sync-period=10s"
1757+
case "${KUBE_PROXY_MODE:-iptables}" in
1758+
iptables)
1759+
params+=" --proxy-mode=iptables --iptables-sync-period=1m --iptables-min-sync-period=10s"
1760+
;;
1761+
ipvs)
1762+
# use 'nf_conntrack' instead of 'nf_conntrack_ipv4' for linux kernel >= 4.19
1763+
# https://github.com/kubernetes/kubernetes/pull/70398
1764+
local -r kernel_version=$(uname -r | cut -d\. -f1,2)
1765+
local conntrack_module="nf_conntrack"
1766+
if [[ $(printf '%s\n4.18\n' "${kernel_version}" | sort -V | tail -1) == "4.18" ]]; then
1767+
conntrack_module="nf_conntrack_ipv4"
1768+
fi
1769+
1770+
if ! sudo modprobe -a ip_vs ip_vs_rr ip_vs_wrr ip_vs_sh ${conntrack_module}; then
1771+
# If IPVS modules are not present, make sure the node does not come up as
1772+
# healthy.
1773+
exit 1
1774+
fi
1775+
params+=" --proxy-mode=ipvs --ipvs-sync-period=1m --ipvs-min-sync-period=10s"
1776+
;;
1777+
nftables)
1778+
# Pass --conntrack-tcp-be-liberal so we can test that this makes the
1779+
# "proxy implementation should not be vulnerable to the invalid conntrack state bug"
1780+
# test pass. https://issues.k8s.io/122663#issuecomment-1885024015
1781+
params+=" --proxy-mode=nftables --conntrack-tcp-be-liberal"
1782+
;;
1783+
esac
1784+
17741785
if [[ -n "${KUBEPROXY_TEST_ARGS:-}" ]]; then
17751786
params+=" ${KUBEPROXY_TEST_ARGS}"
17761787
fi

pkg/features/kube_features.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ const (
525525
// owner: @danwinship
526526
// kep: https://kep.k8s.io/3866
527527
// alpha: v1.29
528+
// beta: v1.31
528529
//
529530
// Allows running kube-proxy with `--mode nftables`.
530531
NFTablesProxyMode featuregate.Feature = "NFTablesProxyMode"
@@ -1131,7 +1132,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
11311132

11321133
NewVolumeManagerReconstruction: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.32
11331134

1134-
NFTablesProxyMode: {Default: false, PreRelease: featuregate.Alpha},
1135+
NFTablesProxyMode: {Default: true, PreRelease: featuregate.Beta},
11351136

11361137
NodeLogQuery: {Default: false, PreRelease: featuregate.Beta},
11371138

pkg/proxy/apis/config/validation/validation_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ func TestValidateKubeProxyConntrackConfiguration(t *testing.T) {
827827
func TestValidateProxyMode(t *testing.T) {
828828
newPath := field.NewPath("KubeProxyConfiguration")
829829
successCases := []kubeproxyconfig.ProxyMode{""}
830-
expectedNonExistentErrorMsg := "must be iptables, ipvs or blank (blank means the best-available proxy [currently iptables])"
830+
expectedNonExistentErrorMsg := "must be iptables, ipvs, nftables or blank (blank means the best-available proxy [currently iptables])"
831831

832832
if runtime.GOOS == "windows" {
833833
successCases = append(successCases, kubeproxyconfig.ProxyModeKernelspace)

0 commit comments

Comments
 (0)