fix: fall back to nftables proxy mode on nftables-only kernels - #5531
Closed
sakiphan wants to merge 1 commit into
Closed
fix: fall back to nftables proxy mode on nftables-only kernels#5531sakiphan wants to merge 1 commit into
sakiphan wants to merge 1 commit into
Conversation
kube-proxy defaults to the iptables proxy mode, which needs the
ip_tables kernel module. On nftables-only kernels this module is
absent, so kube-proxy fails to start ("modprobe: FATAL: Module
ip_tables not found") and the node enters a crash-restart loop that
is not surfaced by `microk8s status` or `microk8s inspect`.
- Add an `is_kernel_module_available` helper to actions/common/utils.sh.
- run-kubelite-with-args now falls back to `--proxy-mode=nftables` when
ip_tables is unavailable and nf_tables can be used, unless the user
has already selected a proxy mode.
- `microk8s inspect` now warns when ip_tables is missing and points to
the manual workaround.
Fixes canonical#5525
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MicroK8s fails silently on nftables-only kernels (kernels shipped without the
ip_tablesmodule). kube-proxy runs in the defaultiptablesproxy mode, whichneeds the
ip_tableskernel module; when it is absent, kube-proxy fails to startwith
modprobe: FATAL: Module ip_tables not foundand the node enters acrash-restart loop. Neither
microk8s statusnormicrok8s inspectsurface thecause — the error is only visible in
journalctl.Fixes #5525
Changes
microk8s-resources/actions/common/utils.sh: add anis_kernel_module_availablehelper that checks
/sys/modulefor loaded/built-in modules and falls back to amodprobe -nqdry-run for loadable ones, mirroring the existingnf_conntrack/br_netfilterhandling inrun-kubelite-with-args.microk8s-resources/wrappers/run-kubelite-with-args: before starting kubelite,if the user has not explicitly set a proxy mode and
ip_tablesis unavailablewhile
nf_tablescan be used, fall back to--proxy-mode=nftables. Auser-selected proxy mode is never overridden, and the check is idempotent across
restarts.
scripts/inspect.sh: add asuggest_fixeswarning that surfaces the missingip_tablesmodule and the manual workaround, for the cases the auto-fallbackcannot cover (e.g.
nf_tablesalso missing, or the user pinned--proxy-mode=iptables).Testing
is_kernel_module_availableagainst a real loaded module (reportsavailable) and a non-existent module name (reports unavailable).
from
run-kubelite-with-args(mocking module availability andrefresh_opt_in_local_config):ip_tablesmissing +nf_tablesavailable + no mode set →--proxy-mode=nftablesaddedip_tablesavailable → no change--proxy-mode=iptables→ preserved, not overridden--proxy-mode=nftables→ unchangedcodespellis clean on the changed files andshellcheckreports no newfindings versus
master.--proxy-mode=nftablesworkaround was confirmed working on the affected hardware by the reporter in bug: microk8s silently fails on nftables-only kernels #5525.
Possible Regressions
ip_tablesis present (the common case) the helper short-circuitsvia
/sys/moduleand no fallback is applied — behavior is unchanged.--proxy-mode(includingiptables) is always respected.nf_tablesis usable; if neither module isavailable no change is made and
microk8s inspectsurfaces the problem instead.1.31, so this is safe on
master/latest. If backported below 1.31 it would requireenabling the
NFTablesProxyModefeature gate.Checklist
Notes
The shell wrappers (
run-kubelite-with-args,inspect.sh) have no in-tree unit-testharness, so the changes were validated manually as described under Testing rather than
with a committed test. Happy to add coverage if you can point me at the preferred place
for wrapper-level tests. This targets
master; let me know if you'd like it backportedand to which release branches.