Skip to content

Commit e555997

Browse files
authored
fix: ensure nf_conntrack module loaded for kubelite. (#4705)
This patch ensures that the `nf_conntrack` kernel module is loaded before `kubelite` is started as the ProxyServer needs to read some conntrack module-related params from procfs. Previously, although the it would always crashed if the module wasn't loaded, this wasn't that common of an occurrence in practice as there are quite a few ways `nf_conntrack` gets loaded transparently: * Cilium [automatically loads `iptable_nat`](https://github.com/cilium/cilium/blob/63cd391f93b4e2c865268241d384504348672042/pkg/datapath/iptables/iptables.go#L367-L368) after a small startup delay, whose dependency tree includes `nf_conntrack` * starting firewalld/ufw/most other firewall services * setting iptables/nftables rules which imply session tracking By explicitly loading `nf_conntrack` before starting `kubelite`, it should ensure the procfs values ther ProxyServer reads are always present on startup. Signed-off-by: Nashwan Azhari <[email protected]>
1 parent c77311b commit e555997

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

microk8s-resources/wrappers/run-kubelite-with-args

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,19 @@ then
204204
fi
205205
fi
206206

207+
# kube-proxy reads some values related to the 'nf_conntrack' kernel
208+
# module from procfs on startup, so we must ensure it is loaded:
209+
if ! [ -f /proc/sys/net/netfilter/nf_conntrack_max ]
210+
then
211+
if /sbin/modprobe nf_conntrack || modprobe nf_conntrack
212+
then
213+
echo "Successfully loaded nf_conntrack module."
214+
else
215+
echo -n "Failed to load nf_conntrack kernel module. "
216+
echo "ProxyServer will fail to start until it's loaded."
217+
fi
218+
fi
219+
207220
# on lxc containers do not try to change the conntrack configuration
208221
# see https://github.com/canonical/microk8s/issues/1438
209222
if grep -E lxc /proc/1/environ &&

0 commit comments

Comments
 (0)