This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 3. Special Resource Operator
Learn about the Special Resource Operator (SRO) and how you can use it to build and manage driver containers for loading kernel modules and device drivers on nodes in an OpenShift Container Platform cluster.
The Special Resource Operator is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.
3.1. About the Special Resource Operator Copier lienLien copié sur presse-papiers!
The Special Resource Operator (SRO) helps you manage the deployment of kernel modules and drivers on an existing OpenShift Container Platform cluster. The SRO can be used for a case as simple as building and loading a single kernel module, or as complex as deploying the driver, device plugin, and monitoring stack for a hardware accelerator.
For loading kernel modules, the SRO is designed around the use of driver containers. Driver containers are increasingly being used in cloud-native environments, especially when run on pure container operating systems, to deliver hardware drivers to the host. Driver containers extend the kernel stack beyond the out-of-the-box software and hardware features of a specific kernel. Driver containers work on various container-capable Linux distributions. With driver containers, the host operating system stays clean and there is no clash between different library versions or binaries on the host.
The functions described require a connected environment with a constant connection to the network. These functions are not available for disconnected environments.
3.2. Installing the Special Resource Operator Copier lienLien copié sur presse-papiers!
As a cluster administrator, you can install the Special Resource Operator (SRO) by using the OpenShift CLI or the web console.
3.2.1. Installing the Special Resource Operator by using the CLI Copier lienLien copié sur presse-papiers!
As a cluster administrator, you can install the Special Resource Operator (SRO) 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 the SRO in the
openshift-operatorsnamespace:Create the following
SubscriptionCR and save the YAML in thesro-sub.yamlfile:Example Subscription CR
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the subscription object by running the following command:
oc create -f sro-sub.yaml
$ oc create -f sro-sub.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Switch to the
openshift-operatorsproject:oc project openshift-operators
$ oc project openshift-operatorsCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
To verify that the Operator deployment is successful, run:
oc get pods
$ oc get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE nfd-controller-manager-7f4c5f5778-4lvvk 2/2 Running 0 89s special-resource-controller-manager-6dbf7d4f6f-9kl8h 2/2 Running 0 81s
NAME READY STATUS RESTARTS AGE nfd-controller-manager-7f4c5f5778-4lvvk 2/2 Running 0 89s special-resource-controller-manager-6dbf7d4f6f-9kl8h 2/2 Running 0 81sCopy to Clipboard Copied! Toggle word wrap Toggle overflow A successful deployment shows a
Runningstatus.
3.2.2. Installing the Special Resource Operator by using the web console Copier lienLien copié sur presse-papiers!
As a cluster administrator, you can install the Special Resource Operator (SRO) by using the OpenShift Container Platform web console.
Procedure
- Log in to the OpenShift Container Platform web console.
Install the Special Resource Operator:
-
In the OpenShift Container Platform web console, click Operators
OperatorHub. - Choose Special Resource Operator from the list of available Operators, and then click Install.
- On the Install Operator page, select a specific namespace on the cluster, select the namespace created in the previous section, and then click Install.
-
In the OpenShift Container Platform web console, click Operators
Verification
To verify that the Special Resource Operator installed successfully:
-
Navigate to the Operators
Installed Operators page. Ensure that Special Resource Operator is listed in the openshift-operators 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.
If the Operator does not appear as installed, to troubleshoot further:
-
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-operatorsproject.
-
Navigate to the Operators
3.3. Using the Special Resource Operator Copier lienLien copié sur presse-papiers!
The Special Resource Operator (SRO) is used to manage the build and deployment of a driver container. The objects required to build and deploy the container can be defined in a Helm chart.
The example in this section uses the simple-kmod SpecialResource object to point to a ConfigMap object that is created to store the Helm charts.
3.3.1. Building and running the simple-kmod SpecialResource by using a config map Copier lienLien copié sur presse-papiers!
In this example, the simple-kmod kernel module shows how the Special Resource Operator (SRO) manages a driver container. The container is defined in the Helm chart templates that are stored in a config map.
Prerequisites
- You have a running OpenShift Container Platform cluster.
-
You set the Image Registry Operator state to
Managedfor your cluster. -
You installed the OpenShift CLI (
oc). -
You are logged into the OpenShift CLI as a user with
cluster-adminprivileges. - You installed the Node Feature Discovery (NFD) Operator.
- You installed the SRO.
-
You installed the Helm CLI (
helm).
Procedure
To create a simple-kmod
SpecialResourceobject, define an image stream and build config to build the image, and a service account, role, role binding, and daemon set to run the container. The service account, role, and role binding are required to run the daemon set with the privileged security context so that the kernel module can be loaded.Create a
templatesdirectory, and change into it:mkdir -p chart/simple-kmod-0.0.1/templates
$ mkdir -p chart/simple-kmod-0.0.1/templatesCopy to Clipboard Copied! Toggle word wrap Toggle overflow cd chart/simple-kmod-0.0.1/templates
$ cd chart/simple-kmod-0.0.1/templatesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Save this YAML template for the image stream and build config in the
templatesdirectory as0000-buildconfig.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Save the following YAML template for the RBAC resources and daemon set in the
templatesdirectory as1000-driver-container.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Change into the
chart/simple-kmod-0.0.1directory:cd ..
$ cd ..Copy to Clipboard Copied! Toggle word wrap Toggle overflow Save the following YAML for the chart as
Chart.yamlin thechart/simple-kmod-0.0.1directory:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
From the
chartdirectory, create the chart using thehelm packagecommand:helm package simple-kmod-0.0.1/
$ helm package simple-kmod-0.0.1/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Successfully packaged chart and saved it to: /data/<username>/git/<github_username>/special-resource-operator/yaml-for-docs/chart/simple-kmod-0.0.1/simple-kmod-0.0.1.tgz
Successfully packaged chart and saved it to: /data/<username>/git/<github_username>/special-resource-operator/yaml-for-docs/chart/simple-kmod-0.0.1/simple-kmod-0.0.1.tgzCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a config map to store the chart files:
Create a directory for the config map files:
mkdir cm
$ mkdir cmCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the Helm chart into the
cmdirectory:cp simple-kmod-0.0.1.tgz cm/simple-kmod-0.0.1.tgz
$ cp simple-kmod-0.0.1.tgz cm/simple-kmod-0.0.1.tgzCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create an index file specifying the Helm repo that contains the Helm chart:
helm repo index cm --url=cm://simple-kmod/simple-kmod-chart
$ helm repo index cm --url=cm://simple-kmod/simple-kmod-chartCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a namespace for the objects defined in the Helm chart:
oc create namespace simple-kmod
$ oc create namespace simple-kmodCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the config map object:
oc create cm simple-kmod-chart --from-file=cm/index.yaml --from-file=cm/simple-kmod-0.0.1.tgz -n simple-kmod
$ oc create cm simple-kmod-chart --from-file=cm/index.yaml --from-file=cm/simple-kmod-0.0.1.tgz -n simple-kmodCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Use the following
SpecialResourcemanifest to deploy the simple-kmod object using the Helm chart that you created in the config map. Save this YAML assimple-kmod-configmap.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow From a command line, create the
SpecialResourcefile:oc create -f simple-kmod-configmap.yaml
$ oc create -f simple-kmod-configmap.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
To remove the simple-kmod kernel module from the node, delete the simple-kmod SpecialResource API object using the oc delete command. The kernel module is unloaded when the driver container pod is deleted.
Verification
The simple-kmod resources are deployed in the simple-kmod namespace as specified in the object manifest. After a short time, the build pod for the simple-kmod driver container starts running. The build completes after a few minutes, and then the driver container pods start running.
Use
oc get podscommand to display the status of the build pods:oc get pods -n simple-kmod
$ oc get pods -n simple-kmodCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE simple-kmod-driver-build-12813789169ac0ee-1-build 0/1 Completed 0 7m12s simple-kmod-driver-container-12813789169ac0ee-mjsnh 1/1 Running 0 8m2s simple-kmod-driver-container-12813789169ac0ee-qtkff 1/1 Running 0 8m2s
NAME READY STATUS RESTARTS AGE simple-kmod-driver-build-12813789169ac0ee-1-build 0/1 Completed 0 7m12s simple-kmod-driver-container-12813789169ac0ee-mjsnh 1/1 Running 0 8m2s simple-kmod-driver-container-12813789169ac0ee-qtkff 1/1 Running 0 8m2sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the
oc logscommand, along with the build pod name obtained from theoc get podscommand above, to display the logs of the simple-kmod driver container image build:oc logs pod/simple-kmod-driver-build-12813789169ac0ee-1-build -n simple-kmod
$ oc logs pod/simple-kmod-driver-build-12813789169ac0ee-1-build -n simple-kmodCopy to Clipboard Copied! Toggle word wrap Toggle overflow To verify that the simple-kmod kernel modules are loaded, execute the
lsmodcommand in one of the driver container pods that was returned from theoc get podscommand above:oc exec -n simple-kmod -it pod/simple-kmod-driver-container-12813789169ac0ee-mjsnh -- lsmod | grep simple
$ oc exec -n simple-kmod -it pod/simple-kmod-driver-container-12813789169ac0ee-mjsnh -- lsmod | grep simpleCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
simple_procfs_kmod 16384 0 simple_kmod 16384 0
simple_procfs_kmod 16384 0 simple_kmod 16384 0Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The sro_kind_completed_info SRO Prometheus metric provides information about the status of the different objects being deployed, which can be useful to troubleshoot SRO CR installations. The SRO also provides other types of metrics that you can use to watch the health of your environment.
3.3.2. Building and running the simple-kmod SpecialResource for a hub-and-spoke topology Copier lienLien copié sur presse-papiers!
You can use the Special Resource Operator (SRO) on a hub-and-spoke deployment in which Red Hat Advanced Cluster Management (RHACM) connects a hub cluster to one or more managed clusters.
This example procedure shows how the SRO builds driver containers in the hub. The SRO watches hub cluster resources to identify OpenShift Container Platform versions for the helm charts that it uses to create resources which it delivers to spokes.
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. - You installed the SRO.
-
You installed the Helm CLI (
helm). - You installed Red Hat Advanced Cluster Management (RHACM).
- You configured a container registry.
Procedure
Create a
templatesdirectory by running the following command:mkdir -p charts/acm-simple-kmod-0.0.1/templates
$ mkdir -p charts/acm-simple-kmod-0.0.1/templatesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Change to the
templatesdirectory by running the following command:cd charts/acm-simple-kmod-0.0.1/templates
$ cd charts/acm-simple-kmod-0.0.1/templatesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create templates files for the
BuildConfig,Policy, andPlacementRuleresources.Save this YAML template for the image stream and build config in the
templatesdirectory as0001-buildconfig.yaml.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Save this YAML template for the ACM policy in the
templatesdirectory as0002-policy.yaml.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Save this YAML template for the placement of policies in the
templatesdirectory as0003-policy.yaml.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Change into the
charts/acm-simple-kmod-0.0.1directory by running the following command:cd ..
cd ..Copy to Clipboard Copied! Toggle word wrap Toggle overflow Save the following YAML template for the chart as
Chart.yamlin thecharts/acm-simple-kmod-0.0.1directory:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
From the
chartsdirectory, create the chart using the command:helm package acm-simple-kmod-0.0.1/
$ helm package acm-simple-kmod-0.0.1/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Successfully packaged chart and saved it to: <directory>/charts/acm-simple-kmod-0.0.1.tgz
Successfully packaged chart and saved it to: <directory>/charts/acm-simple-kmod-0.0.1.tgzCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a config map to store the chart files.
Create a directory for the config map files by running the following command:
mkdir cm
$ mkdir cmCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the Helm chart into the
cmdirectory by running the following command:cp acm-simple-kmod-0.0.1.tgz cm/acm-simple-kmod-0.0.1.tgz
$ cp acm-simple-kmod-0.0.1.tgz cm/acm-simple-kmod-0.0.1.tgzCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create an index file specifying the Helm repository that contains the Helm chart by running the following command:
helm repo index cm --url=cm://acm-simple-kmod/acm-simple-kmod-chart
$ helm repo index cm --url=cm://acm-simple-kmod/acm-simple-kmod-chartCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a namespace for the objects defined in the Helm chart by running the following command:
oc create namespace acm-simple-kmod
$ oc create namespace acm-simple-kmodCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the config map object by running the following command:
oc create cm acm-simple-kmod-chart --from-file=cm/index.yaml --from-file=cm/acm-simple-kmod-0.0.1.tgz -n acm-simple-kmod
$ oc create cm acm-simple-kmod-chart --from-file=cm/index.yaml --from-file=cm/acm-simple-kmod-0.0.1.tgz -n acm-simple-kmodCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Use the following
SpecialResourceModulemanifest to deploy thesimple-kmodobject using the Helm chart that you created in the config map. Save this YAML file asacm-simple-kmod.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the URL for a registry that you have configured.
Create the special resource module by running the following command:
oc apply -f charts/examples/acm-simple-kmod.yaml
$ oc apply -f charts/examples/acm-simple-kmod.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Check the status of the build pods by running the following command:
KUBECONFIG=~/hub/auth/kubeconfig oc get pod -n acm-simple-kmod
$ KUBECONFIG=~/hub/auth/kubeconfig oc get pod -n acm-simple-kmodCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE acm-simple-kmod-4-18-0-305-34-2-el8-4-x86-64-1-build 0/1 Completed 0 42m
NAME READY STATUS RESTARTS AGE acm-simple-kmod-4-18-0-305-34-2-el8-4-x86-64-1-build 0/1 Completed 0 42mCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check that the policies have been created by running the following command:
KUBECONFIG=~/hub/auth/kubeconfig oc get placementrules,placementbindings,policies -n acm-simple-kmod
$ KUBECONFIG=~/hub/auth/kubeconfig oc get placementrules,placementbindings,policies -n acm-simple-kmodCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check that the resources have been reconciled by running the following command:
KUBECONFIG=~/hub/auth/kubeconfig oc get specialresourcemodule acm-simple-kmod -o json | jq -r '.status'
$ KUBECONFIG=~/hub/auth/kubeconfig oc get specialresourcemodule acm-simple-kmod -o json | jq -r '.status'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check that the resources are running in the spoke by running the following command:
KUBECONFIG=~/spoke1/kubeconfig oc get ds,pod -n acm-simple-kmod
$ KUBECONFIG=~/spoke1/kubeconfig oc get ds,pod -n acm-simple-kmodCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.4. Prometheus Special Resource Operator metrics Copier lienLien copié sur presse-papiers!
The Special Resource Operator (SRO) exposes the following Prometheus metrics through the metrics service:
| Metric Name | Description |
|---|---|
|
|
Returns the nodes that are running pods created by a SRO custom resource (CR). This metric is available for |
|
|
Represents whether a |
|
|
Represents whether the SRO has finished processing a CR successfully (value |
|
| Returns the number of SRO CRs in the cluster, regardless of their state. |