1.3. Adding kernel modules to nodes
For most common hardware, the Linux kernel includes the device driver modules needed to use that hardware when the computer starts up. For some hardware, however, modules are not available in Linux. Therefore, you must find a way to provide those modules to each host computer. This procedure describes how to do that for nodes in an OpenShift Container Platform cluster.
When a kernel module is first deployed by following these instructions, the module is made available for the current kernel. If a new kernel is installed, the kmods-via-containers software will rebuild and deploy the module so a compatible version of that module is available with the new kernel.
The way that this feature is able to keep the module up to date on each node is by:
- Adding a systemd service to each node that starts at boot time to detect if a new kernel has been installed and
- If a new kernel is detected, the service rebuilds the module and installs it to the kernel
For information on the software needed for this procedure, see the kmods-via-containers github site.
A few important issues to keep in mind:
- This procedure is Technology Preview.
-
Software tools and examples are not yet available in official RPM form and can only be obtained for now from unofficial
github.comsites noted in the procedure. - Third-party kernel modules you might add through these procedures are not supported by Red Hat.
-
In this procedure, the software needed to build your kernel modules is deployed in a RHEL 8 container. Keep in mind that modules are rebuilt automatically on each node when that node gets a new kernel. For that reason, each node needs access to a
yumrepository that contains the kernel and related packages needed to rebuild the module. That content is best provided with a valid RHEL subscription.
1.3.1. Building and testing the kernel module container 링크 복사링크가 클립보드에 복사되었습니다!
Before deploying kernel modules to your OpenShift Container Platform cluster, you can test the process on a separate RHEL system. Gather the kernel module’s source code, the KVC framework, and the kmod-via-containers software. Then build and test the module. To do that on a RHEL 8 system, do the following:
Procedure
Register a RHEL 8 system:
# subscription-manager registerAttach a subscription to the RHEL 8 system:
# subscription-manager attach --autoInstall software that is required to build the software and container:
# yum install podman make git -yClone the
kmod-via-containersrepository:Create a folder for the repository:
$ mkdir kmods; cd kmodsClone the repository:
$ git clone https://github.com/kmods-via-containers/kmods-via-containers
Install a KVC framework instance on your RHEL 8 build host to test the module. This adds a
kmods-via-containersystemd service and loads it:Change to the
kmod-via-containersdirectory:$ cd kmods-via-containers/Install the KVC framework instance:
$ sudo make installReload the systemd manager configuration:
$ sudo systemctl daemon-reload
Get the kernel module source code. The source code might be used to build a third-party module that you do not have control over, but is supplied by others. You will need content similar to the content shown in the
kvc-simple-kmodexample that can be cloned to your system as follows:$ cd .. ; git clone https://github.com/kmods-via-containers/kvc-simple-kmodEdit the configuration file,
simple-kmod.conffile, in this example, and change the name of the Dockerfile toDockerfile.rhel:Change to the
kvc-simple-kmoddirectory:$ cd kvc-simple-kmodRename the Dockerfile:
$ cat simple-kmod.confExample Dockerfile
KMOD_CONTAINER_BUILD_CONTEXT="https://github.com/kmods-via-containers/kvc-simple-kmod.git" KMOD_CONTAINER_BUILD_FILE=Dockerfile.rhel KMOD_SOFTWARE_VERSION=dd1a7d4 KMOD_NAMES="simple-kmod simple-procfs-kmod"
Create an instance of
kmods-via-containers@.servicefor your kernel module,simple-kmodin this example:$ sudo make installEnable the
kmods-via-containers@.serviceinstance:$ sudo kmods-via-containers build simple-kmod $(uname -r)Enable and start the systemd service:
$ sudo systemctl enable kmods-via-containers@simple-kmod.service --nowReview the service status:
$ sudo systemctl status kmods-via-containers@simple-kmod.serviceExample output
● kmods-via-containers@simple-kmod.service - Kmods Via Containers - simple-kmod Loaded: loaded (/etc/systemd/system/kmods-via-containers@.service; enabled; vendor preset: disabled) Active: active (exited) since Sun 2020-01-12 23:49:49 EST; 5s ago...
To confirm that the kernel modules are loaded, use the
lsmodcommand to list the modules:$ lsmod | grep simple_Example output
simple_procfs_kmod 16384 0 simple_kmod 16384 0Optional. Use other methods to check that the
simple-kmodexample is working:Look for a "Hello world" message in the kernel ring buffer with
dmesg:$ dmesg | grep 'Hello world'Example output
[ 6420.761332] Hello world from simple_kmod.Check the value of
simple-procfs-kmodin/proc:$ sudo cat /proc/simple-procfs-kmodExample output
simple-procfs-kmod number = 0Run the
spkutcommand to get more information from the module:$ sudo spkut 44Example output
KVC: wrapper simple-kmod for 4.21.0-147.3.1.el8_1.x86_64 Running userspace wrapper using the kernel module container... + podman run -i --rm --privileged simple-kmod-dd1a7d4:4.21.0-147.3.1.el8_1.x86_64 spkut 44 simple-procfs-kmod number = 0 simple-procfs-kmod number = 44
Going forward, when the system boots this service will check if a new kernel is running. If there is a new kernel, the service builds a new version of the kernel module and then loads it. If the module is already built, it will just load it.