K3s’s eBPF integration unlocks powerful kernel-level networking features, but it’s surprisingly easy to misconfigure the underlying kernel modules.

The most common culprit is a missing or improperly loaded cgroup_ipv6 kernel module. K3s relies on eBPF for advanced network policy enforcement and load balancing, and this module is crucial for correctly associating network events with cgroups, which Kubernetes uses to manage pods.

Diagnosis: Check if the cgroup_ipv6 module is loaded:

lsmod | grep cgroup_ipv6

If you see no output, the module is not loaded.

Fix: Load the module manually:

sudo modprobe cgroup_ipv6

This tells the kernel to load the module, making its functionality available for eBPF programs.

A close second is an outdated kernel version that lacks sufficient eBPF support. K3s targets relatively modern kernels, and older ones might not expose the necessary hooks or features for eBPF to operate correctly.

Diagnosis: Check your kernel version:

uname -r

Compare this to the K3s documentation for recommended kernel versions. Generally, kernels older than 4.14 might have limited eBPF capabilities.

Fix: Update your kernel to a supported version. This is distribution-specific. For example, on Ubuntu:

sudo apt update
sudo apt upgrade linux-image-generic
sudo reboot

A newer kernel provides the necessary eBPF infrastructure, allowing K3s to properly attach and execute its network programs.

Incorrectly configured sysctl parameters related to networking or BPF can also cause issues. K3s might expect certain network buffers or BPF map sizes to be larger than the system’s defaults.

Diagnosis: Check relevant sysctl values:

sudo sysctl net.core.somaxconn
sudo sysctl net.ipv4.tcp_max_syn_backlog
sudo sysctl bpf.max_entries

Compare these to recommended values in K3s or Kubernetes networking guides.

Fix: Adjust sysctl parameters persistently. Edit /etc/sysctl.conf or a file in /etc/sysctl.d/:

net.core.somaxconn = 4096
net.ipv4.tcp_max_syn_backlog = 2048
bpf.max_entries = 1048576

Apply them:

sudo sysctl -p

Increasing these values provides more room for network connections and BPF maps, preventing resource exhaustion errors.

Sometimes, the kernel.unprivileged_bpf_disabled sysctl setting can prevent K3s from using BPF features if it’s not running as root or if the user agent is not explicitly allowed.

Diagnosis: Check the setting:

sudo sysctl kernel.unprivileged_bpf_disabled

A value of 1 means unprivileged BPF is disabled.

Fix: Allow unprivileged BPF usage (use with caution):

sudo sysctl kernel.unprivileged_bpf_disabled=0

To make this persistent, add kernel.unprivileged_bpf_disabled = 0 to /etc/sysctl.conf or a file in /etc/sysctl.d/ and run sudo sysctl -p. This allows K3s to leverage BPF features even when not running with full root privileges, which is common in containerized environments.

A less common but critical issue is insufficient memory allocated for BPF maps. Each eBPF program uses maps to store data, and if the system runs out of memory for these maps, programs will fail to attach or execute.

Diagnosis: Monitor memory usage, especially for kernel memory, and look for OOM killer events related to BPF. Tools like bpftool map list can show map sizes, and dmesg can reveal OOM messages.

Fix: Increase system memory or tune BPF map limits if possible (this is more advanced and often involves kernel compilation options or specific module parameters, but a general increase in RAM is the most straightforward solution). This ensures there’s enough physical memory for the kernel to allocate to BPF data structures.

Finally, ensure the kernel.kptr_restrict sysctl is not set to 2, which can prevent eBPF programs from accessing necessary kernel symbols.

Diagnosis: Check the setting:

sudo sysctl kernel.kptr_restrict

A value of 2 restricts kernel pointer exposure.

Fix: Set kernel.kptr_restrict to 1 or 0:

sudo sysctl kernel.kptr_restrict=1

Add kernel.kptr_restrict = 1 to /etc/sysctl.conf or a file in /etc/sysctl.d/ and run sudo sysctl -p. This allows eBPF programs to resolve certain kernel symbols they need to function correctly.

After resolving these, you’ll likely encounter an error related to CNI plugin network configuration, as eBPF often works in tandem with the chosen CNI.

Want structured learning?

Take the full K3s course →