Automatic modprobe (enable Linux Kernel module) at boot time

Written by - 0 comments

Published on - Listed in Linux Kubernetes Systemd


While fiddling with kubeadm to run a local Kubernetes cluster, I ran into an error:

root@kube1:~# kubeadm init --config=kubeadm-config.yaml --upload-certs
[init] Using Kubernetes version: v1.24.1
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
    [ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]: /proc/sys/net/bridge/bridge-nf-call-iptables does not exist
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

This error showed up although the sysctl config contains the relevant values:

root@kube1:~# cat /etc/sysctl.d/kubernetes.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1

But when manually looking inside the procfs, the "bridge" part is missing in the path:

root@kube1:~# ll /proc/sys/net/
core/      ipv4/      ipv6/      netfilter/ unix/

A "bridge" directory should be there so sysctl can actually set these values.

In this situation, the "bridge" directory is missing because the relevant Kernel module (br_netfilter) is not loaded:

root@kube1:~# lsmod|grep netfilt
[... nothing ...]

Of course you can now run modprobe to manually load the module:

root@kube1:~# modprobe br_netfilter
root@kube1:~# lsmod|grep netfilter
br_netfilter           28672  0
bridge                176128  1 br_netfilter

But this won't survive a reboot.

As a workaround you could place the command "modprobe br_netfilter" into /etc/rc.local, once execution of rc.local is enabled. But there's a proper solution on distributions with Systemd: /etc/modules-load.d or /etc/modules.

By simply adding the module name(s) to load upon boot time into one of the *.conf files inside /etc/modules-load.d, these modules will be loaded during boot. As /etc/modules-load.d/modules.conf is a symlink to /etc/modules, I'm using this file:

root@kube1:~# echo "br_netfilter" >> /etc/modules

Of course you could also use a dedicated .conf file for this purpose.

After a system reboot, you will notice that br_netfilter is now listed under lsmod.

The Kubernetes cluster can now be created with kubeadm:

root@kube1:~# kubeadm init --config=kubeadm-config.yaml --upload-certs
[...]
Your Kubernetes control-plane has initialized successfully!
[...]



Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   OpenSearch   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder