@@ -1753,24 +1753,35 @@ function prepare-kube-proxy-manifest-variables {
1753
1753
if [[ -n " ${FEATURE_GATES:- } " ]]; then
1754
1754
params+=" --feature-gates=${FEATURE_GATES} "
1755
1755
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
1764
1756
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
+
1774
1785
if [[ -n " ${KUBEPROXY_TEST_ARGS:- } " ]]; then
1775
1786
params+=" ${KUBEPROXY_TEST_ARGS} "
1776
1787
fi
0 commit comments