Chapter 3. Using the Compliance Operator
3.1. Using the Compliance Operator with Red Hat Advanced Cluster Security for Kubernetes Copy linkLink copied to clipboard!
You can configure RHACS to use the Compliance Operator for compliance reporting and remediation with OpenShift Container Platform clusters. Results from the Compliance Operator can be reported in the RHACS Compliance Dashboard.
3.1.1. Installing the Compliance Operator Copy linkLink copied to clipboard!
Install the Compliance Operator using Operator Hub.
Procedure
Install the Operator by performing the following steps:
-
Navigate in the web console to the Operators
OperatorHub page. - Enter compliance operator into the Filter by keyword box to find the Compliance Operator.
- Select the Compliance Operator to view the details page.
- Read the information about the Operator and click Install.
3.1.2. Configuring the ScanSettingBinding object Copy linkLink copied to clipboard!
Create a ScanSettingBinding object in the openshift-compliance namespace to scan the cluster using the cis and cis-node profiles.
This example uses cis and cis-node profiles, but OpenShift Container Platform provides additional profiles. See "Understanding the Compliance Operator" in the "Additional resources" section for more information.
Procedure
Select one of the following options:
Use the CLI to create the YAML file and object. For example:
Create a file called
sscan.yamlusing the following text:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
ScanSettingBindingobject by running the following command:oc create -f sscan.yaml -n openshift-compliance
$ oc create -f sscan.yaml -n openshift-complianceCopy to Clipboard Copied! Toggle word wrap Toggle overflow If successful, the following message is displayed:
scansettingbinding.compliance.openshift.io/cis-compliance created
$ scansettingbinding.compliance.openshift.io/cis-compliance createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Use the web console to create the object by performing the following steps:
-
Change the active project to
openshift-compliance. - Click + to open the Import YAML window.
- Paste the YAML from the previous example and then click Create.
-
Change the active project to
Additional resources
- Understanding the Compliance Operator
- Compliance Operator scans in OpenShift Container Platform
Optional: If you installed the Compliance Operator after installing RHACS, restart Sensor in the secured cluster by performing one of the following options:
Run the following command:
oc -n stackrox delete pod -lapp=sensor
$ oc -n stackrox delete pod -lapp=sensorCopy to Clipboard Copied! Toggle word wrap Toggle overflow In the OpenShift Container Platform web console, perform the following steps:
-
Change the active project to
stackrox. -
Navigate to Workloads
Pods. -
Locate the pod with the name starting with
sensor-, and then click ActionsDelete Pod.
-
Change the active project to
Verification
After performing these steps, run a compliance scan in RHACS and ensure that ocp4-cis and ocp4-cis-node results are displayed. See "Running a compliance scan" in the "Additional resources" section for more information.
Additional resources