Repository navigation
k3s: Let pods reach the kubelet with the bundled network - #31
Merged
Merged
Conversation
checks.k3s failed now and then at the metrics-server subtest (3 of the 7 failed CI attempts since 2026-11-15): every scrape of the kubelet at 192.168.1.1:10250 timed out, so metrics-server never got Ready. In all three runs k3s never logged "Starting network policy controller", which it does 2-3 s after the kubelet in passing runs. With the bundled network, the rule that lets pod traffic to the node in ahead of the NixOS firewall comes from that controller (KUBE-ROUTER-INPUT). k3s starts it once the Ready condition of the node carries a heartbeat no older than the controller's start, truncated to the second. When the kubelet posts Ready in the second before, the next heartbeat comes with the kubelet's periodic status report, 5 minutes on, past the subtest's 300 s. The firewall only opens 6443, so it drops the scrapes until then. Opens 10250 on cni0 when bundledNetworking is on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 19, 2026
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.
checks.k3shas failed now and then at the metrics-server subtest since 2026-11-15. This is the cause and the fix.What the failing runs show
Three CI attempts failed at this subtest (runs 43767292207, 44390246564 and 44590951510, all on attempt 1). They all look the same: every metrics-server scrape of the kubelet times out, for the whole 300 s:
The APIService stays
MissingEndpointsbecause the pod never gets Ready. In none of the three does k3s logStarting network policy controller. Passing runs log it 2–3 s after the kubelet starts.Why
KUBE-ROUTER-INPUTat the top ofINPUT, and that chain accepts traffic from pods that comply with policy. The NixOS firewall comes after it and only opens 6443. A local dump from a passing run shows metrics-server's packets going through itsKUBE-ROUTER-INPUTpod chain.pkg/agent/netpol/netpol.goat v1.35.8+k3s1). Before starting, it waits for the node's Ready condition to carry a heartbeat no older thanstartTime := time.Now().Truncate(time.Second). If the kubelet posted Ready in an earlier second, k3s waits for the next status post. Once the node has settled, the kubelet only posts atnodeStatusReportFrequency, which defaults to 5m. That is past the subtest's 300 s.Fast updating node status as it just became readywith flannel's lines just beforenetpol.Run:So the runner isn't just slow. The scrapes are dropped for a full 5 minutes whenever that one-second race goes the wrong way.
Fix
When
bundledNetworkingis on, open 10250 oncni0. That lets pods reach the kubelet no matter when the controller starts. Once the controller is up, its rule accepts this traffic before the firewall sees it anyway, so the steady state doesn't change.Verified locally
--disable-network-policy) with refused-connection logging on. Without the fix, metrics-server never gets Ready and the kernel logsrefused connection: IN=cni0 … SRC=10.42.0.4 DST=192.168.1.1 … DPT=10250. With the fix it is Ready.checks.k3swith the fix, 5 runs: the metrics subtest passed in all 5. In one of them (rep 3) the race hit and netpol never started. The metrics subtest still passed, in 21 s.owner-nameofkube-apiserver-kubelet-adminnever becameprune-test). That is a different flake and so are the three other failed CI attempts since 2026-11-15. Each time, k3s's deploy controller re-applied every manifest in name order just as the test linkedprune-test.yamlin, androlebindings.yamlwas applied right after it and took the binding back. It is not touched here.Open decision
10250 only, or trust
cni0entirely. Trusting it would match what k3s allows once netpol runs (pods reach every node port unless an egress policy says otherwise). It would also cover pod→node traffic other than the kubelet during the startup window. I went with the narrower rule.🤖 Generated with Claude Code