Este conteúdo não está disponível no idioma selecionado.
Chapter 4. Kernel Module Management Operator
Learn about the Kernel Module Management (KMM) Operator and how you can use it to deploy out-of-tree kernel modules and device plugins on OpenShift Container Platform clusters.
4.1. About the Kernel Module Management Operator Copiar o linkLink copiado para a área de transferência!
The Kernel Module Management (KMM) Operator manages, builds, signs, and deploys out-of-tree kernel modules and device plugins on OpenShift Container Platform clusters.
KMM adds a new Module CRD which describes an out-of-tree kernel module and its associated device plugin. You can use Module resources to configure how to load the module, define ModuleLoader images for kernel versions, and include instructions for building and signing modules for specific kernel versions.
KMM is designed to accommodate multiple kernel versions at once for any kernel module, allowing for seamless node upgrades and reduced application downtime.
4.2. Installing the Kernel Module Management Operator Copiar o linkLink copiado para a área de transferência!
As a cluster administrator, you can install the Kernel Module Management (KMM) Operator by using the OpenShift CLI or the web console.
The KMM Operator is supported on OpenShift Container Platform 4.12 and later. Installing KMM on version 4.11 does not require specific additional steps. For details on installing KMM on version 4.10 and earlier, see the section "Installing the Kernel Module Management Operator on earlier versions of OpenShift Container Platform".
4.2.1. Installing the Kernel Module Management Operator using the web console Copiar o linkLink copiado para a área de transferência!
As a cluster administrator, you can install the Kernel Module Management (KMM) Operator using the OpenShift Container Platform web console.
Procedure
- Log in to the OpenShift Container Platform web console.
Install the Kernel Module Management Operator:
-
In the OpenShift Container Platform web console, click Operators
OperatorHub. - Select Kernel Module Management Operator from the list of available Operators, and then click Install.
-
From the Installed Namespace list, select the
openshift-kmmnamespace. - Click Install.
-
In the OpenShift Container Platform web console, click Operators
Verification
To verify that KMM Operator installed successfully:
-
Navigate to the Operators
Installed Operators page. Ensure that Kernel Module Management Operator is listed in the openshift-kmm project with a Status of InstallSucceeded.
NoteDuring installation, an Operator might display a Failed status. If the installation later succeeds with an InstallSucceeded message, you can ignore the Failed message.
Troubleshooting
To troubleshoot issues with Operator installation:
-
Navigate to the Operators
Installed Operators page and inspect the Operator Subscriptions and Install Plans tabs for any failure or errors under Status. -
Navigate to the Workloads
Pods page and check the logs for pods in the openshift-kmmproject.
-
Navigate to the Operators
4.2.2. Installing the Kernel Module Management Operator by using the CLI Copiar o linkLink copiado para a área de transferência!
As a cluster administrator, you can install the Kernel Module Management (KMM) Operator by using the OpenShift CLI.
Prerequisites
- You have a running OpenShift Container Platform cluster.
-
You installed the OpenShift CLI (
oc). -
You are logged into the OpenShift CLI as a user with
cluster-adminprivileges.
Procedure
Install KMM in the
openshift-kmmnamespace:Create the following
NamespaceCR and save the YAML file, for example,kmm-namespace.yaml:apiVersion: v1 kind: Namespace metadata: name: openshift-kmm
apiVersion: v1 kind: Namespace metadata: name: openshift-kmmCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the following
OperatorGroupCR and save the YAML file, for example,kmm-op-group.yaml:apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: kernel-module-management namespace: openshift-kmm
apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: kernel-module-management namespace: openshift-kmmCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the following
SubscriptionCR and save the YAML file, for example,kmm-sub.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the subscription object by running the following command:
oc create -f kmm-sub.yaml
$ oc create -f kmm-sub.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
To verify that the Operator deployment is successful, run the following command:
oc get -n openshift-kmm deployments.apps kmm-operator-controller-manager
$ oc get -n openshift-kmm deployments.apps kmm-operator-controller-managerCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY UP-TO-DATE AVAILABLE AGE kmm-operator-controller-manager 1/1 1 1 97s
NAME READY UP-TO-DATE AVAILABLE AGE kmm-operator-controller-manager 1/1 1 1 97sCopy to Clipboard Copied! Toggle word wrap Toggle overflow The Operator is available.
4.2.3. Installing the Kernel Module Management Operator on earlier versions of OpenShift Container Platform Copiar o linkLink copiado para a área de transferência!
The KMM Operator is supported on OpenShift Container Platform 4.12 and later. For version 4.10 and earlier, you must create a new SecurityContextConstraint object and bind it to the Operator’s ServiceAccount. As a cluster administrator, you can install the Kernel Module Management (KMM) Operator by using the OpenShift CLI.
Prerequisites
- You have a running OpenShift Container Platform cluster.
-
You installed the OpenShift CLI (
oc). -
You are logged into the OpenShift CLI as a user with
cluster-adminprivileges.
Procedure
Install KMM in the
openshift-kmmnamespace:Create the following
NamespaceCR and save the YAML file, for example,kmm-namespace.yamlfile:apiVersion: v1 kind: Namespace metadata: name: openshift-kmm
apiVersion: v1 kind: Namespace metadata: name: openshift-kmmCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the following
SecurityContextConstraintobject and save the YAML file, for example,kmm-security-constraint.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Bind the
SecurityContextConstraintobject to the Operator’sServiceAccountby running the following commands:oc apply -f kmm-security-constraint.yaml
$ oc apply -f kmm-security-constraint.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow oc adm policy add-scc-to-user kmm-security-constraint -z kmm-operator-controller-manager -n openshift-kmm
$ oc adm policy add-scc-to-user kmm-security-constraint -z kmm-operator-controller-manager -n openshift-kmmCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the following
OperatorGroupCR and save the YAML file, for example,kmm-op-group.yaml:apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: kernel-module-management namespace: openshift-kmm
apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: kernel-module-management namespace: openshift-kmmCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the following
SubscriptionCR and save the YAML file, for example,kmm-sub.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the subscription object by running the following command:
oc create -f kmm-sub.yaml
$ oc create -f kmm-sub.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
To verify that the Operator deployment is successful, run the following command:
oc get -n openshift-kmm deployments.apps kmm-operator-controller-manager
$ oc get -n openshift-kmm deployments.apps kmm-operator-controller-managerCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY UP-TO-DATE AVAILABLE AGE kmm-operator-controller-manager 1/1 1 1 97s
NAME READY UP-TO-DATE AVAILABLE AGE kmm-operator-controller-manager 1/1 1 1 97sCopy to Clipboard Copied! Toggle word wrap Toggle overflow The Operator is available.
4.3. Uninstalling the Kernel Module Management Operator Copiar o linkLink copiado para a área de transferência!
Use one of the following procedures to uninstall the Kernel Module Management (KMM) Operator, depending on how the KMM Operator was installed.
4.3.1. Uninstalling a Red Hat catalog installation Copiar o linkLink copiado para a área de transferência!
Use this procedure if KMM was installed from the Red Hat catalog.
Procedure
Use the following method to uninstall the KMM Operator:
- Use the OpenShift console under Operators -→ Installed Operators to locate and uninstall the Operator.
Alternatively, you can delete the Subscription resource in the KMM namespace.
4.3.2. Uninstalling a CLI installation Copiar o linkLink copiado para a área de transferência!
Use this command if the KMM Operator was installed using the OpenShift CLI.
Procedure
Run the following command to uninstall the KMM Operator:
oc delete -k https://github.com/rh-ecosystem-edge/kernel-module-management/config/default
$ oc delete -k https://github.com/rh-ecosystem-edge/kernel-module-management/config/defaultCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteUsing this command deletes the
ModuleCRD and allModuleinstances in the cluster.
4.4. Kernel module deployment Copiar o linkLink copiado para a área de transferência!
For each Module resource, Kernel Module Management (KMM) can create a number of DaemonSet resources:
-
One ModuleLoader
DaemonSetper compatible kernel version running in the cluster. -
One device plugin
DaemonSet, if configured.
The module loader daemon set resources run ModuleLoader images to load kernel modules. A module loader image is an OCI image that contains the .ko files and both the modprobe and sleep binaries.
When the module loader pod is created, the pod runs modprobe to insert the specified module into the kernel. It then enters a sleep state until it is terminated. When that happens, the ExecPreStop hook runs modprobe -r to unload the kernel module.
If the .spec.devicePlugin attribute is configured in a Module resource, then KMM creates a device plugin daemon set in the cluster. That daemon set targets:
-
Nodes that match the
.spec.selectorof theModuleresource. -
Nodes with the kernel module loaded (where the module loader pod is in the
Readycondition).
4.4.1. The Module custom resource definition Copiar o linkLink copiado para a área de transferência!
The Module custom resource definition (CRD) represents a kernel module that can be loaded on all or select nodes in the cluster, through a module loader image. A Module custom resource (CR) specifies one or more kernel versions with which it is compatible, and a node selector.
The compatible versions for a Module resource are listed under .spec.moduleLoader.container.kernelMappings. A kernel mapping can either match a literal version, or use regexp to match many of them at the same time.
The reconciliation loop for the Module resource runs the following steps:
-
List all nodes matching
.spec.selector. - Build a set of all kernel versions running on those nodes.
For each kernel version:
-
Go through
.spec.moduleLoader.container.kernelMappingsand find the appropriate container image name. If the kernel mapping hasbuildorsigndefined and the container image does not already exist, run the build, the signing job, or both, as needed. - Create a module loader daemon set with the container image determined in the previous step.
-
If
.spec.devicePluginis defined, create a device plugin daemon set using the configuration specified under.spec.devicePlugin.container.
-
Go through
Run
garbage-collecton:- Existing daemon set resources targeting kernel versions that are not run by any node in the cluster.
- Successful build jobs.
- Successful signing jobs.
4.4.2. Set soft dependencies between kernel modules Copiar o linkLink copiado para a área de transferência!
Some configurations require that several kernel modules be loaded in a specific order to work properly, even though the modules do not directly depend on each other through symbols. These are called soft dependencies. depmod is usually not aware of these dependencies, and they do not appear in the files it produces. For example, if mod_a has a soft dependency on mod_b, modprobe mod_a will not load mod_b.
You can resolve these situations by declaring soft dependencies in the Module Custom Resource Definition (CRD) using the modulesLoadingOrder field.
In the configuration above:
-
The loading order is
mod_b, thenmod_a. -
The unloading order is
mod_a, thenmod_b.
The first value in the list, to be loaded last, must be equivalent to the moduleName.
4.4.3. Security and permissions Copiar o linkLink copiado para a área de transferência!
Loading kernel modules is a highly sensitive operation. After they are loaded, kernel modules have all possible permissions to do any kind of operation on the node.
4.4.3.1. ServiceAccounts and SecurityContextConstraints Copiar o linkLink copiado para a área de transferência!
Kernel Module Management (KMM) creates a privileged workload to load the kernel modules on nodes. That workload needs ServiceAccounts allowed to use the privileged SecurityContextConstraint (SCC) resource.
The authorization model for that workload depends on the namespace of the Module resource, as well as its spec.
-
If the
.spec.moduleLoader.serviceAccountNameor.spec.devicePlugin.serviceAccountNamefields are set, they are always used. If those fields are not set, then:
-
If the
Moduleresource is created in the operator’s namespace (openshift-kmmby default), then KMM uses its default, powerfulServiceAccountsto run the daemon sets. -
If the
Moduleresource is created in any other namespace, then KMM runs the daemon sets as the namespace’sdefaultServiceAccount. TheModuleresource cannot run a privileged workload unless you manually enable it to use theprivilegedSCC.
-
If the
openshift-kmm is a trusted namespace.
When setting up RBAC permissions, remember that any user or ServiceAccount creating a Module resource in the openshift-kmm namespace results in KMM automatically running privileged workloads on potentially all nodes in the cluster.
To allow any ServiceAccount to use the privileged SCC and therefore to run module loader or device plugin pods, use the following command:
oc adm policy add-scc-to-user privileged -z "${serviceAccountName}" [ -n "${namespace}" ]
$ oc adm policy add-scc-to-user privileged -z "${serviceAccountName}" [ -n "${namespace}" ]
4.4.3.2. Pod security standards Copiar o linkLink copiado para a área de transferência!
OpenShift runs a synchronization mechanism that sets the namespace Pod Security level automatically based on the security contexts in use. No action is needed.
4.5. Replacing in-tree modules with out-of-tree modules Copiar o linkLink copiado para a área de transferência!
You can use Kernel Module Management (KMM) to build kernel modules that can be loaded or unloaded into the kernel on demand. These modules extend the functionality of the kernel without the need to reboot the system. Modules can be configured as built-in or dynamically loaded.
Dynamically loaded modules include in-tree modules and out-of-tree (OOT) modules. In-tree modules are internal to the Linux kernel tree, that is, they are already part of the kernel. Out-of-tree modules are external to the Linux kernel tree. They are generally written for development and testing purposes, such as testing the new version of a kernel module that is shipped in-tree, or to deal with incompatibilities.
Some modules loaded by KMM could replace in-tree modules already loaded on the node. To unload an in-tree module before loading your module, set the .spec.moduleLoader.container.inTreeModuleToRemove field. The following is an example for module replacement for all kernel mappings:
In this example, the moduleLoader pod uses inTreeModuleToRemove to unload the in-tree mod_b before loading mod_a from the moduleLoader image. When the moduleLoader`pod is terminated and `mod_a is unloaded, mod_b is not loaded again.
The following is an example for module replacement for specific kernel mappings:
4.5.1. Example Module CR Copiar o linkLink copiado para a área de transferência!
The following is an annotated Module example:
- 1 1 1
- Required.
- 2
- Optional.
- 3
- Optional: Copies
/firmware/*into/var/lib/firmware/on the node. - 4
- Optional.
- 5
- At least one kernel item is required.
- 6
- For each node running a kernel matching the regular expression, KMM creates a
DaemonSetresource running the image specified incontainerImagewith${KERNEL_FULL_VERSION}replaced with the kernel version. - 7
- For any other kernel, build the image using the Dockerfile in the
my-kmodConfigMap. - 8
- Optional.
- 9
- Optional: A value for
some-kubernetes-secretcan be obtained from the build environment at/run/secrets/some-kubernetes-secret. - 10
- Optional: Avoid using this parameter. If set to
true, the build is allowed to pull the image in the DockerfileFROMinstruction using plain HTTP. - 11
- Optional: Avoid using this parameter. If set to
true, the build will skip any TLS server certificate validation when pulling the image in the DockerfileFROMinstruction using plain HTTP. - 12
- Required.
- 13
- Required: A secret holding the public secureboot key with the key 'cert'.
- 14
- Required: A secret holding the private secureboot key with the key 'key'.
- 15
- Optional: Avoid using this parameter. If set to
true, KMM will be allowed to check if the container image already exists using plain HTTP. - 16
- Optional: Avoid using this parameter. If set to
true, KMM will skip any TLS server certificate validation when checking if the container image already exists. - 17
- Optional.
- 18
- Optional.
- 19
- Required: If the device plugin section is present.
- 20
- Optional.
- 21
- Optional.
- 22
- Optional.
- 23
- Optional: Used to pull module loader and device plugin images.
4.6. Using a ModuleLoader image Copiar o linkLink copiado para a área de transferência!
Kernel Module Management (KMM) works with purpose-built module loader images. These are standard OCI images that must satisfy the following requirements:
-
.kofiles must be located in/opt/lib/modules/${KERNEL_VERSION}. -
modprobeandsleepbinaries must be defined in the$PATHvariable.
4.6.1. Running depmod Copiar o linkLink copiado para a área de transferência!
If your module loader image contains several kernel modules and if one of the modules depends on another module, it is best practice to run depmod at the end of the build process to generate dependencies and map files.
You must have a Red Hat subscription to download the kernel-devel package.
Procedure
-
To generate
modules.depand.mapfiles for a specific kernel version, rundepmod -b /opt ${KERNEL_VERSION}.
4.6.1.1. Example Dockerfile Copiar o linkLink copiado para a área de transferência!
If you are building your image on OpenShift Container Platform, consider using the Driver Tool Kit (DTK).
For further information, see using an entitled build.
4.6.2. Building in the cluster Copiar o linkLink copiado para a área de transferência!
KMM can build module loader images in the cluster. Follow these guidelines:
-
Provide build instructions using the
buildsection of a kernel mapping. -
Copy the Dockerfile for your container image into a
ConfigMapresource, under thedockerfilekey. -
Ensure that the
ConfigMapis located in the same namespace as theModule.
KMM checks if the image name specified in the containerImage field exists. If it does, the build is skipped.
Otherwise, KMM creates a Build resource to build your image. After the image is built, KMM proceeds with the Module reconciliation. See the following example.
- 1
- Optional.
- 2
- Optional.
- 3
- Will be mounted in the build pod as
/run/secrets/some-kubernetes-secret. - 4
- Optional: Avoid using this parameter. If set to
true, the build will be allowed to pull the image in the DockerfileFROMinstruction using plain HTTP. - 5
- Optional: Avoid using this parameter. If set to
true, the build will skip any TLS server certificate validation when pulling the image in the DockerfileFROMinstruction using plain HTTP. - 6
- Required.
- 7
- Optional: Avoid using this parameter. If set to
true, KMM will be allowed to check if the container image already exists using plain HTTP. - 8
- Optional: Avoid using this parameter. If set to
true, KMM will skip any TLS server certificate validation when checking if the container image already exists.
4.6.3. Using the Driver Toolkit Copiar o linkLink copiado para a área de transferência!
The Driver Toolkit (DTK) is a convenient base image for building build module loader images. It contains tools and libraries for the OpenShift version currently running in the cluster.
Procedure
Use DTK as the first stage of a multi-stage Dockerfile.
- Build the kernel modules.
-
Copy the
.kofiles into a smaller end-user image such asubi-minimal. To leverage DTK in your in-cluster build, use the
DTK_AUTObuild argument. The value is automatically set by KMM when creating theBuildresource. See the following example.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.7. Using signing with Kernel Module Management (KMM) Copiar o linkLink copiado para a área de transferência!
On a Secure Boot enabled system, all kernel modules (kmods) must be signed with a public/private key-pair enrolled into the Machine Owner’s Key (MOK) database. Drivers distributed as part of a distribution should already be signed by the distribution’s private key, but for kernel modules build out-of-tree, KMM supports signing kernel modules using the sign section of the kernel mapping.
For more details on using Secure Boot, see Generating a public and private key pair
Prerequisites
- A public private key pair in the correct (DER) format.
- At least one secure-boot enabled node with the public key enrolled in its MOK database.
- Either a pre-built driver container image, or the source code and Dockerfile needed to build one in-cluster.
4.8. Adding the keys for secureboot Copiar o linkLink copiado para a área de transferência!
To use KMM Kernel Module Management (KMM) to sign kernel modules, a certificate and private key are required. For details on how to create these, see Generating a public and private key pair.
For details on how to extract the public and private key pair, see Signing kernel modules with the private key. Use steps 1 through 4 to extract the keys into files.
Procedure
Create the
sb_cert.cerfile that contains the certificate and thesb_cert.privfile that contains the private key:openssl req -x509 -new -nodes -utf8 -sha256 -days 36500 -batch -config configuration_file.config -outform DER -out my_signing_key_pub.der -keyout my_signing_key.priv
$ openssl req -x509 -new -nodes -utf8 -sha256 -days 36500 -batch -config configuration_file.config -outform DER -out my_signing_key_pub.der -keyout my_signing_key.privCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the files by using one of the following methods:
Add the files as secrets directly:
oc create secret generic my-signing-key --from-file=key=<my_signing_key.priv>
$ oc create secret generic my-signing-key --from-file=key=<my_signing_key.priv>Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc create secret generic my-signing-key-pub --from-file=cert=<my_signing_key_pub.der>
$ oc create secret generic my-signing-key-pub --from-file=cert=<my_signing_key_pub.der>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the files by base64 encoding them:
cat sb_cert.priv | base64 -w 0 > my_signing_key2.base64
$ cat sb_cert.priv | base64 -w 0 > my_signing_key2.base64Copy to Clipboard Copied! Toggle word wrap Toggle overflow cat sb_cert.cer | base64 -w 0 > my_signing_key_pub.base64
$ cat sb_cert.cer | base64 -w 0 > my_signing_key_pub.base64Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Add the encoded text to a YAML file:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the YAML file:
oc apply -f <yaml_filename>
$ oc apply -f <yaml_filename>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.8.1. Checking the keys Copiar o linkLink copiado para a área de transferência!
After you have added the keys, you must check them to ensure they are set correctly.
Procedure
Check to ensure the public key secret is set correctly:
oc get secret -o yaml <certificate secret name> | awk '/cert/{print $2; exit}' | base64 -d | openssl x509 -inform der -text$ oc get secret -o yaml <certificate secret name> | awk '/cert/{print $2; exit}' | base64 -d | openssl x509 -inform der -textCopy to Clipboard Copied! Toggle word wrap Toggle overflow This should display a certificate with a Serial Number, Issuer, Subject, and more.
Check to ensure the private key secret is set correctly:
oc get secret -o yaml <private key secret name> | awk '/key/{print $2; exit}' | base64 -d$ oc get secret -o yaml <private key secret name> | awk '/key/{print $2; exit}' | base64 -dCopy to Clipboard Copied! Toggle word wrap Toggle overflow This should display the key enclosed in the
-----BEGIN PRIVATE KEY-----and-----END PRIVATE KEY-----lines.
4.9. Signing a pre-built driver container Copiar o linkLink copiado para a área de transferência!
Use this procedure if you have a pre-built image, such as an image either distributed by a hardware vendor or built elsewhere.
The following YAML file adds the public/private key-pair as secrets with the required key names - key for the private key, cert for the public key. The cluster then pulls down the unsignedImage image, opens it, signs the kernel modules listed in filesToSign, adds them back, and pushes the resulting image as containerImage.
Kernel Module Management (KMM) should then deploy the DaemonSet that loads the signed kmods onto all the nodes that match the selector. The driver containers should run successfully on any nodes that have the public key in their MOK database, and any nodes that are not secure-boot enabled, which ignore the signature. They should fail to load on any that have secure-boot enabled but do not have that key in their MOK database.
Prerequisites
-
The
keySecretandcertSecretsecrets have been created.
Procedure
Apply the YAML file:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
- 1
modprobe- The name of the kmod to load.
4.10. Building and signing a ModuleLoader container image Copiar o linkLink copiado para a área de transferência!
Use this procedure if you have source code and must build your image first.
The following YAML file builds a new container image using the source code from the repository. The image produced is saved back in the registry with a temporary name, and this temporary image is then signed using the parameters in the sign section.
The temporary image name is based on the final image name and is set to be <containerImage>:<tag>-<namespace>_<module name>_kmm_unsigned.
For example, using the following YAML file, Kernel Module Management (KMM) builds an image named example.org/repository/minimal-driver:final-default_example-module_kmm_unsigned containing the build with unsigned kmods and push it to the registry. Then it creates a second image named example.org/repository/minimal-driver:final that contains the signed kmods. It is this second image that is loaded by the DaemonSet object and deploys the kmods to the cluster nodes.
After it is signed, the temporary image can be safely deleted from the registry. It will be rebuilt, if needed.
Prerequisites
-
The
keySecretandcertSecretsecrets have been created.
Procedure
Apply the YAML file:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
- 1 2
namespace- Replacedefaultwith a valid namespace.- 3
serviceAccountName- The defaultserviceAccountNamedoes not have the required permissions to run a module that is privileged. For information on creating a service account, see "Creating service accounts" in the "Additional resources" of this section.- 4
imageRepoSecret- Used asimagePullSecretsin theDaemonSetobject and to pull and push for the build and sign features.
4.11. KMM hub and spoke Copiar o linkLink copiado para a área de transferência!
In hub and spoke scenarios, many spoke clusters are connected to a central, powerful hub cluster. Kernel Module Management (KMM) depends on Red Hat Advanced Cluster Management (RHACM) to operate in hub and spoke environments.
KMM is compatible with hub and spoke environments through decoupling KMM features. A ManagedClusterModule Custom Resource Definition (CRD) is provided to wrap the existing Module CRD and extend it to select Spoke clusters. Also provided is KMM-Hub, a new standalone controller that builds images and signs modules on the hub cluster.
In hub and spoke setups, spokes are focused, resource-constrained clusters that are centrally managed by a hub cluster. Spokes run the single-cluster edition of KMM, with those resource-intensive features disabled. To adapt KMM to this environment, you should reduce the workload running on the spokes to the minimum, while the hub takes care of the expensive tasks.
Building kernel module images and signing the .ko files, should run on the hub. The scheduling of the Module Loader and Device Plugin DaemonSets can only happen on the spokes.
4.11.1. KMM-Hub Copiar o linkLink copiado para a área de transferência!
The KMM project provides KMM-Hub, an edition of KMM dedicated to hub clusters. KMM-Hub monitors all kernel versions running on the spokes and determines the nodes on the cluster that should receive a kernel module.
KMM-Hub runs all compute-intensive tasks such as image builds and kmod signing, and prepares the trimmed-down Module to be transferred to the spokes through RHACM.
KMM-Hub cannot be used to load kernel modules on the hub cluster. Install the regular edition of KMM to load kernel modules.
4.11.2. Installing KMM-Hub Copiar o linkLink copiado para a área de transferência!
You can use one of the following methods to install KMM-Hub:
- Using the Operator Lifecycle Manager (OLM)
- Creating KMM resources
4.11.2.1. Installing KMM-Hub using the Operator Lifecycle Manager Copiar o linkLink copiado para a área de transferência!
Use the Operators section of the OpenShift console to install KMM-Hub.
4.11.2.2. Installing KMM-Hub by creating KMM resources Copiar o linkLink copiado para a área de transferência!
Procedure
-
If you want to install KMM-Hub programmatically, you can use the following resources to create the
Namespace,OperatorGroupandSubscriptionresources:
4.11.3. Using the ManagedClusterModule CRD Copiar o linkLink copiado para a área de transferência!
Use the ManagedClusterModule Custom Resource Definition (CRD) to configure the deployment of kernel modules on spoke clusters. This CRD is cluster-scoped, wraps a Module spec and adds the following additional fields:
If build or signing instructions are present in .spec.moduleSpec, those pods are run on the hub cluster in the operator’s namespace.
When the .spec.selector matches one or more ManagedCluster resources, then KMM-Hub creates a ManifestWork resource in the corresponding namespace(s). ManifestWork contains a trimmed-down Module resource, with kernel mappings preserved but all build and sign subsections are removed. containerImage fields that contain image names ending with a tag are replaced with their digest equivalent.
4.11.4. Running KMM on the spoke Copiar o linkLink copiado para a área de transferência!
After installing Kernel Module Management (KMM) on the spoke, no further action is required. Create a ManagedClusterModule object from the hub to deploy kernel modules on spoke clusters.
Procedure
You can install KMM on the spokes cluster through a RHACM Policy object. In addition to installing KMM from the OperatorHub and running it in a lightweight spoke mode, the Policy configures additional RBAC required for the RHACM agent to be able to manage Module resources.
4.12. Customizing upgrades for kernel modules Copiar o linkLink copiado para a área de transferência!
Use this procedure to upgrade the kernel module while running maintenance operations on the node, including rebooting the node, if needed. To minimize the impact on the workloads running in the cluster, run the kernel upgrade process sequentially, one node at a time.
This procedure requires knowledge of the workload utilizing the kernel module and must be managed by the cluster administrator.
Prerequisites
-
Before upgrading, set the
kmm.node.kubernetes.io/version-module.<module_namespace>.<module_name>=$moduleVersionlabel on all the nodes that are used by the kernel module. - Terminate all user application workloads on the node or move them to another node.
- Unload the currently loaded kernel module.
- Ensure that the user workload (the application running in the cluster that is accessing kernel module) is not running on the node prior to kernel module unloading and that the workload is back running on the node after the new kernel module version has been loaded.
Procedure
- Ensure that the device plugin managed by KMM on the node is unloaded.
Update the following fields in the
Modulecustom resource (CR):-
containerImage(to the appropriate kernel version) versionThe update should be atomic; that is, both the
containerImageandversionfields must be updated simultaneously.
-
- Terminate any workload using the kernel module on the node being upgraded.
Remove the
kmm.node.kubernetes.io/version-module.<module_namespace>.<module_name>label on the node. Run the following command to unload the kernel module from the node:oc label node/<node_name> kmm.node.kubernetes.io/version-module.<module_namespace>.<module_name>-
$ oc label node/<node_name> kmm.node.kubernetes.io/version-module.<module_namespace>.<module_name>-Copy to Clipboard Copied! Toggle word wrap Toggle overflow If required, as the cluster administrator, perform any additional maintenance required on the node for the kernel module upgrade.
If no additional upgrading is needed, you can skip Steps 3 through 6 by updating the
kmm.node.kubernetes.io/version-module.<module-namespace>.<module-name>label value to the new$moduleVersionas set in theModule.Run the following command to add the
kmm.node.kubernetes.io/version-module.<module_namespace>.<module_name>=$moduleVersionlabel to the node. The$moduleVersionmust be equal to the new value of theversionfield in theModuleCR.oc label node/<node_name> kmm.node.kubernetes.io/version-module.<module_namespace>.<module_name>=<desired_version>
$ oc label node/<node_name> kmm.node.kubernetes.io/version-module.<module_namespace>.<module_name>=<desired_version>Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteBecause of Kubernetes limitations in label names, the combined length of
Modulename and namespace must not exceed 39 characters.- Restore any workload that leverages the kernel module on the node.
- Reload the device plugin managed by KMM on the node.
4.13. Day 1 kernel module loading Copiar o linkLink copiado para a área de transferência!
Kernel Module Management (KMM) is typically a Day 2 Operator. Kernel modules are loaded only after the complete initialization of a Linux (RHCOS) server. However, in some scenarios the kernel module must be loaded at an earlier stage. Day 1 functionality allows you to use the Machine Config Operator (MCO) to load kernel modules during the Linux systemd initialization stage.
4.13.1. Day 1 supported use cases Copiar o linkLink copiado para a área de transferência!
The Day 1 functionality supports a limited number of use cases. The main use case is to allow loading out-of-tree (OOT) kernel modules prior to NetworkManager service initialization. It does not support loading kernel module at the initramfs stage.
The following are the conditions needed for Day 1 functionality:
- The kernel module is not loaded in the kernel.
- The in-tree kernel module is loaded into the kernel, but can be unloaded and replaced by the OOT kernel module. This means that the in-tree module is not referenced by any other kernel modules.
- In order for Day 1 functionlity to work, the node must have a functional network interface, that is, an in-tree kernel driver for that interface. The OOT kernel module can be a network driver that will replace the functional network driver.
4.13.2. OOT kernel module loading flow Copiar o linkLink copiado para a área de transferência!
The loading of the out-of-tree (OOT) kernel module leverages the Machine Config Operator (MCO). The flow sequence is as follows:
Procedure
-
Apply a
MachineConfigresource to the existing running cluster. In order to identify the necessary nodes that need to be updated, you must create an appropriateMachineConfigPoolresource. -
MCO applies the reboots node by node. On any rebooted node, two new
systemdservices are deployed:pullservice andloadservice. -
The
loadservice is configured to run prior to theNetworkConfigurationservice. The service tries to pull a predefined kernel module image and then, using that image, to unload an in-tree module and load an OOT kernel module. -
The
pullservice is configured to run after NetworkManager service. The service checks if the preconfigured kernel module image is located on the node’s filesystem. If it is, the service exists normally, and the server continues with the boot process. If not, it pulls the image onto the node and reboots the node afterwards.
4.13.3. The kernel module image Copiar o linkLink copiado para a área de transferência!
The Day 1 functionality uses the same DTK based image leveraged by Day 2 KMM builds. The out-of-tree kernel module should be located under /opt/lib/modules/${kernelVersion}.
4.13.4. In-tree module replacement Copiar o linkLink copiado para a área de transferência!
The Day 1 functionality always tries to replace the in-tree kernel module with the OOT version. If the in-tree kernel module is not loaded, the flow is not affected; the service proceeds and loads the OOT kernel module.
4.13.5. MCO yaml creation Copiar o linkLink copiado para a área de transferência!
KMM provides an API to create an MCO YAML manifest for the Day 1 functionality:
ProduceMachineConfig(machineConfigName, machineConfigPoolRef, kernelModuleImage, kernelModuleName string) (string, error)
ProduceMachineConfig(machineConfigName, machineConfigPoolRef, kernelModuleImage, kernelModuleName string) (string, error)
The returned output is a string representation of the MCO YAML manifest to be applied. It is up to the customer to apply this YAML.
The parameters are:
machineConfigName-
The name of the MCO YAML manifest. This parameter is set as the
nameparameter of the metadata of the MCO YAML manifest. machineConfigPoolRef-
The
MachineConfigPoolname used to identify the targeted nodes. kernelModuleImage- The name of the container image that includes the OOT kernel module.
kernelModuleName- The name of the OOT kernel module. This parameter is used both to unload the in-tree kernel module (if loaded into the kernel) and to load the OOT kernel module.
The API is located under pkg/mcproducer package of the KMM source code. The KMM operator does not need to be running to use the Day 1 functionality. You only need to import the pkg/mcproducer package into their operator/utility code, call the API, and apply the produced MCO YAML to the cluster.
4.13.6. The MachineConfigPool Copiar o linkLink copiado para a área de transferência!
The MachineConfigPool identifies a collection of nodes that are affected by the applied MCO.
There are predefined MachineConfigPools in the OCP cluster:
-
worker: Targets all worker nodes in the cluster -
master: Targets all master nodes in the cluster
Define the following MachineConfig to target the master MachineConfigPool:
metadata:
labels:
machineconfiguration.opensfhit.io/role: master
metadata:
labels:
machineconfiguration.opensfhit.io/role: master
Define the following MachineConfig to target the worker MachineConfigPool:
metadata:
labels:
machineconfiguration.opensfhit.io/role: worker
metadata:
labels:
machineconfiguration.opensfhit.io/role: worker
4.14. Debugging and troubleshooting Copiar o linkLink copiado para a área de transferência!
If the kmods in your driver container are not signed or are signed with the wrong key, then the container can enter a PostStartHookError or CrashLoopBackOff status. You can verify by running the oc describe command on your container, which displays the following message in this scenario:
modprobe: ERROR: could not insert '<your_kmod_name>': Required key not available
modprobe: ERROR: could not insert '<your_kmod_name>': Required key not available
4.15. KMM firmware support Copiar o linkLink copiado para a área de transferência!
Kernel modules sometimes need to load firmware files from the file system. KMM supports copying firmware files from the ModuleLoader image to the node’s file system.
The contents of .spec.moduleLoader.container.modprobe.firmwarePath are copied into the /var/lib/firmware path on the node before running the modprobe command to insert the kernel module.
All files and empty directories are removed from that location before running the modprobe -r command to unload the kernel module, when the pod is terminated.
4.15.1. Configuring the lookup path on nodes Copiar o linkLink copiado para a área de transferência!
On OpenShift Container Platform nodes, the set of default lookup paths for firmwares does not include the /var/lib/firmware path.
Procedure
Use the Machine Config Operator to create a
MachineConfigcustom resource (CR) that contains the/var/lib/firmwarepath:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- You can configure the label based on your needs. In the case of single-node OpenShift, use either
control-paneormasterobjects.
-
By applying the
MachineConfigCR, the nodes are automatically rebooted.
4.15.2. Building a ModuleLoader image Copiar o linkLink copiado para a área de transferência!
Procedure
In addition to building the kernel module itself, include the binary firmware in the builder image:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.15.3. Tuning the Module resource Copiar o linkLink copiado para a área de transferência!
Procedure
Set
.spec.moduleLoader.container.modprobe.firmwarePathin theModulecustom resource (CR):Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Optional: Copies
/firmware/*into/var/lib/firmware/on the node.
4.16. Troubleshooting KMM Copiar o linkLink copiado para a área de transferência!
When troubleshooting KMM installation issues, you can monitor logs to determine at which stage issues occur. Then, retrieve diagnostic data relevant to that stage.
4.16.1. Using the must-gather tool Copiar o linkLink copiado para a área de transferência!
The oc adm must-gather command is the preferred way to collect a support bundle and provide debugging information to Red Hat Support. Collect specific information by running the command with the appropriate arguments as described in the following sections.
4.16.1.1. Gathering data for KMM Copiar o linkLink copiado para a área de transferência!
Procedure
Gather the data for the KMM Operator controller manager:
Set the
MUST_GATHER_IMAGEvariable:export MUST_GATHER_IMAGE=$(oc get deployment -n openshift-kmm kmm-operator-controller-manager -ojsonpath='{.spec.template.spec.containers[?(@.name=="manager")].env[?(@.name=="RELATED_IMAGES_MUST_GATHER")].value}')$ export MUST_GATHER_IMAGE=$(oc get deployment -n openshift-kmm kmm-operator-controller-manager -ojsonpath='{.spec.template.spec.containers[?(@.name=="manager")].env[?(@.name=="RELATED_IMAGES_MUST_GATHER")].value}')Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteUse the
-n <namespace>switch to specify a namespace if you installed KMM in a custom namespace.Run the
must-gathertool:oc adm must-gather --image="${MUST_GATHER_IMAGE}" -- /usr/bin/gather$ oc adm must-gather --image="${MUST_GATHER_IMAGE}" -- /usr/bin/gatherCopy to Clipboard Copied! Toggle word wrap Toggle overflow
View the Operator logs:
oc logs -fn openshift-kmm deployments/kmm-operator-controller-manager
$ oc logs -fn openshift-kmm deployments/kmm-operator-controller-managerCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example 4.1. Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.16.1.2. Gathering data for KMM-Hub Copiar o linkLink copiado para a área de transferência!
Procedure
Gather the data for the KMM Operator hub controller manager:
Set the
MUST_GATHER_IMAGEvariable:export MUST_GATHER_IMAGE=$(oc get deployment -n openshift-kmm-hub kmm-operator-hub-controller-manager -ojsonpath='{.spec.template.spec.containers[?(@.name=="manager")].env[?(@.name=="RELATED_IMAGES_MUST_GATHER")].value}')$ export MUST_GATHER_IMAGE=$(oc get deployment -n openshift-kmm-hub kmm-operator-hub-controller-manager -ojsonpath='{.spec.template.spec.containers[?(@.name=="manager")].env[?(@.name=="RELATED_IMAGES_MUST_GATHER")].value}')Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteUse the
-n <namespace>switch to specify a namespace if you installed KMM in a custom namespace.Run the
must-gathertool:oc adm must-gather --image="${MUST_GATHER_IMAGE}" -- /usr/bin/gather -u$ oc adm must-gather --image="${MUST_GATHER_IMAGE}" -- /usr/bin/gather -uCopy to Clipboard Copied! Toggle word wrap Toggle overflow
View the Operator logs:
oc logs -fn openshift-kmm-hub deployments/kmm-operator-hub-controller-manager
$ oc logs -fn openshift-kmm-hub deployments/kmm-operator-hub-controller-managerCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example 4.2. Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow