Skip to content

Commit 05af58f

Browse files
authored
Merge pull request #51875 from sheriff-rh/CMP-1618
CMP-1618 update Compliance Operator docs
2 parents afab978 + 37796aa commit 05af58f

31 files changed

+590
-333
lines changed

modules/compliance-anatomy.adoc

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,34 @@ The compliance content is stored in `Profile` objects that are generated from a
1313

1414
[source,terminal]
1515
----
16-
$ oc get profilebundle.compliance
16+
$ oc get -n openshift-compliance profilebundle.compliance
1717
----
1818

1919
[source,terminal]
2020
----
21-
$ oc get profile.compliance
21+
$ oc get -n openshift-compliance profile.compliance
2222
----
2323

2424
The `ProfileBundle` objects are processed by deployments labeled with the `Bundle` name. To troubleshoot an issue with the `Bundle`, you can find the deployment and view logs of the pods in a deployment:
2525

2626
[source,terminal]
2727
----
28-
$ oc logs -lprofile-bundle=ocp4 -c profileparser
28+
$ oc logs -n openshift-compliance -lprofile-bundle=ocp4 -c profileparser
2929
----
3030

3131
[source,terminal]
3232
----
33-
$ oc get deployments,pods -lprofile-bundle=ocp4
33+
$ oc get -n openshift-compliance deployments,pods -lprofile-bundle=ocp4
3434
----
3535

3636
[source,terminal]
3737
----
38-
$ oc logs pods/<pod-name>
38+
$ oc logs -n openshift-compliance pods/<pod-name>
3939
----
4040

4141
[source,terminal]
4242
----
43-
$ oc describe pod/<pod-name> -c profileparser
43+
$ oc describe -n openshift-compliance pod/<pod-name> -c profileparser
4444
----
4545

4646
[id="compliance-anatomy-scan-setting-scan-binding-lifecycle_{context}"]
@@ -123,14 +123,15 @@ In this phase, several config maps that contain either environment for the scann
123123

124124
[source,terminal]
125125
----
126-
$ oc get cm -lcompliance.openshift.io/scan-name=rhcos4-e8-worker,complianceoperator.openshift.io/scan-script=
126+
$ oc -n openshift-compliance get cm \
127+
-l compliance.openshift.io/scan-name=rhcos4-e8-worker,complianceoperator.openshift.io/scan-script=
127128
----
128129

129130
These config maps will be used by the scanner pods. If you ever needed to modify the scanner behavior, change the scanner debug level or print the raw results, modifying the config maps is the way to go. Afterwards, a persistent volume claim is created per scan to store the raw ARF results:
130131

131132
[source,terminal]
132133
----
133-
$ oc get pvc -lcompliance.openshift.io/scan-name=<scan_name>
134+
$ oc get pvc -n openshift-compliance -lcompliance.openshift.io/scan-name=rhcos4-e8-worker
134135
----
135136

136137
The PVCs are mounted by a per-scan `ResultServer` deployment. A `ResultServer` is a simple HTTP server where the individual scanner pods upload the full ARF results to. Each server can run on a different node. The full ARF results might be very large and you cannot presume that it would be possible to create a volume that could be mounted from multiple nodes at the same time. After the scan is finished, the `ResultServer` deployment is scaled down. The PVC with the raw results can be mounted from another custom pod and the results can be fetched or inspected. The traffic between the scanner pods and the `ResultServer` is protected by mutual TLS protocols.
@@ -147,8 +148,9 @@ $ oc get pods -lcompliance.openshift.io/scan-name=rhcos4-e8-worker,workload=scan
147148
----
148149
NAME READY STATUS RESTARTS AGE LABELS
149150
rhcos4-e8-worker-ip-10-0-169-90.eu-north-1.compute.internal-pod 0/2 Completed 0 39m compliance.openshift.io/scan-name=rhcos4-e8-worker,targetNode=ip-10-0-169-90.eu-north-1.compute.internal,workload=scanner
150-
At this point, the scan proceeds to the Running phase.
151151
----
152+
+
153+
The scan then proceeds to the Running phase.
152154

153155
[id="compliance-scan-running-phase_{context}"]
154156
=== Running phase
@@ -158,7 +160,7 @@ The running phase waits until the scanner pods finish. The following terms and p
158160

159161
* *scanner*: This container runs the scan. For node scans, the container mounts the node filesystem as `/host` and mounts the content delivered by the init container. The container also mounts the `entrypoint` `ConfigMap` created in the Launching phase and executes it. The default script in the entrypoint `ConfigMap` executes OpenSCAP and stores the result files in the `/results` directory shared between the pod's containers. Logs from this pod can be viewed to determine what the OpenSCAP scanner checked. More verbose output can be viewed with the `debug` flag.
160162

161-
* *logcollector*: The logcollector container waits until the scanner container finishes. Then, it uploads the full ARF results to the `ResultServer` and separately uploads the XCCDF results along with scan result and OpenSCAP result code as a `ConfigMap.` These result config maps are labeled with the scan name (`compliance.openshift.io/scan-name=<scan_name>`):
163+
* *logcollector*: The logcollector container waits until the scanner container finishes. Then, it uploads the full ARF results to the `ResultServer` and separately uploads the XCCDF results along with scan result and OpenSCAP result code as a `ConfigMap.` These result config maps are labeled with the scan name (`compliance.openshift.io/scan-name=rhcos4-e8-worker`):
162164
+
163165
[source,terminal]
164166
----
@@ -243,7 +245,8 @@ It is also possible to trigger a re-run of a scan in the Done phase by annotatin
243245

244246
[source,terminal]
245247
----
246-
$ oc annotate compliancescans/<scan_name> compliance.openshift.io/rescan=
248+
$ oc -n openshift-compliance \
249+
annotate compliancescans/rhcos4-e8-worker compliance.openshift.io/rescan=
247250
----
248251

249252
After the scan reaches the Done phase, nothing else happens on its own unless the remediations are set to be applied automatically with `autoApplyRemediations: true`. The {product-title} administrator would now review the remediations and apply them as needed. If the remediations are set to be applied automatically, the `ComplianceSuite` controller takes over in the Done phase, pauses the machine config pool to which the scan maps to and applies all the remediations in one go. If a remediation is applied, the `ComplianceRemediation` controller takes over.
@@ -299,14 +302,16 @@ The remediation loop ends once the rendered machine config is updated, if needed
299302

300303
[source,terminal]
301304
----
302-
$ oc annotate compliancescans/<scan_name> compliance.openshift.io/rescan=
305+
$ oc -n openshift-compliance \
306+
annotate compliancescans/rhcos4-e8-worker compliance.openshift.io/rescan=
303307
----
304308

305309
The scan will run and finish. Check for the remediation to pass:
306310

307311
[source,terminal]
308312
----
309-
$ oc get compliancecheckresults/rhcos4-e8-worker-audit-rules-dac-modification-chmod
313+
$ oc -n openshift-compliance \
314+
get compliancecheckresults/rhcos4-e8-worker-audit-rules-dac-modification-chmod
310315
----
311316

312317
.Example output

modules/compliance-apply-remediation-for-customized-mcp.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Do not set `protectKernelDefaults: false` in the `KubeletConfig` file, because t
1515
+
1616
[source,terminal]
1717
----
18-
$ oc get nodes
18+
$ oc get nodes -n openshift-compliance
1919
----
2020
+
2121
.Example output
@@ -34,7 +34,9 @@ ip-10-0-197-35.us-east-2.compute.internal Ready master 5h22m v1.25.0
3434
+
3535
[source,terminal]
3636
----
37-
$ oc label node ip-10-0-166-81.us-east-2.compute.internal node-role.kubernetes.io/<machine_config_pool_name>=
37+
$ oc -n openshift-compliance \
38+
label node ip-10-0-166-81.us-east-2.compute.internal \
39+
node-role.kubernetes.io/<machine_config_pool_name>=
3840
----
3941
+
4042
.Example output

modules/compliance-apply-remediations-from-scans.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ Although you can use the `autoApplyRemediations` boolean parameter in a `Complia
1414
1515
[source,terminal]
1616
----
17-
$ oc annotate compliancesuites/<suite-_name> compliance.openshift.io/apply-remediations=
17+
$ oc -n openshift-compliance \
18+
annotate compliancesuites/workers-compliancesuite compliance.openshift.io/apply-remediations=
1819
----

modules/compliance-applying.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ The boolean attribute `spec.apply` controls whether the remediation should be ap
99

1010
[source,terminal]
1111
----
12-
$ oc patch complianceremediations/<scan_name>-sysctl-net-ipv4-conf-all-accept-redirects --patch '{"spec":{"apply":true}}' --type=merge
12+
$ oc -n openshift-compliance \
13+
patch complianceremediations/<scan-name>-sysctl-net-ipv4-conf-all-accept-redirects \
14+
--patch '{"spec":{"apply":true}}' --type=merge
1315
----
1416

1517
After the Compliance Operator processes the applied remediation, the `status.ApplicationState` attribute would change to *Applied* or to *Error* if incorrect. When a machine config remediation is applied, that remediation along with all other applied remediations are rendered into a `MachineConfig` object named `75-$scan-name-$suite-name`. That `MachineConfig` object is subsequently rendered by the Machine Config Operator and finally applied to all the nodes in a machine config pool by an instance of the machine control daemon running on each node.

modules/compliance-auto-update-remediations.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ In some cases, a scan with newer content might mark remediations as `OUTDATED`.
1414
1515
[source,terminal]
1616
----
17-
$ oc annotate compliancesuites/<suite_name> compliance.openshift.io/remove-outdated=
17+
$ oc -n openshift-compliance \
18+
annotate compliancesuites/workers-compliancesuite compliance.openshift.io/remove-outdated=
1819
----
1920

2021
Alternatively, set the `autoUpdateRemediations` flag in a `ScanSetting` or `ComplianceSuite` object to update the remediations automatically.

modules/compliance-crd-compliance-check-result.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ status: FAIL <2>
4646
To get all the check results from a suite, run the following command:
4747
[source,terminal]
4848
----
49-
oc get compliancecheckresults -l compliance.openshift.io/suite=<suit name>
49+
oc get compliancecheckresults \
50+
-l compliance.openshift.io/suite=workers-compliancesuite
5051
----

modules/compliance-crd-compliance-remediation.adoc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,20 @@ spec:
5353
To get all the remediations from a suite, run the following command:
5454
[source,terminal]
5555
----
56-
oc get complianceremediations -l compliance.openshift.io/suite=<suite name>
56+
oc get complianceremediations \
57+
-l compliance.openshift.io/suite=workers-compliancesuite
5758
----
5859

5960
To list all failing checks that can be remediated automatically, run the following command:
6061
[source,terminal]
6162
----
62-
oc get compliancecheckresults -l 'compliance.openshift.io/check-status in (FAIL),compliance.openshift.io/automated-remediation'
63+
oc get compliancecheckresults \
64+
-l 'compliance.openshift.io/check-status in (FAIL),compliance.openshift.io/automated-remediation'
6365
----
6466

6567
To list all failing checks that can be remediated manually, run the following command:
6668
[source,terminal]
6769
----
68-
oc get compliancecheckresults -l 'compliance.openshift.io/check-status in (FAIL),!compliance.openshift.io/automated-remediation'
70+
oc get compliancecheckresults \
71+
-l 'compliance.openshift.io/check-status in (FAIL),!compliance.openshift.io/automated-remediation'
6972
----

modules/compliance-crd-profile-bundle.adoc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
:_content-type: CONCEPT
66
[id="profile-bundle-object_{context}"]
77
= ProfileBundle object
8-
When you install the Compliance Operator, it includes ready-to-run `ProfileBundle` object. The Compliance Operator parses the `ProfileBundle` object and creates a `Profile` object for each profile in the bundle. It also parses `Rule` and `Variable` objects, which are used by the `Profile` object.
8+
When you install the Compliance Operator, it includes ready-to-run `ProfileBundle` objects. The Compliance Operator parses the `ProfileBundle` object and creates a `Profile` object for each profile in the bundle. It also parses `Rule` and `Variable` objects, which are used by the `Profile` object.
99

1010

1111
.Example `ProfileBundle` object
@@ -15,15 +15,10 @@ apiVersion: compliance.openshift.io/v1alpha1
1515
kind: ProfileBundle
1616
name: <profile bundle name>
1717
namespace: openshift-compliance
18-
spec:
19-
contentFile: ssg-ocp4-ds.xml <1>
20-
contentImage: quay.io/complianceascode/ocp4:latest <2>
2118
status:
22-
dataStreamStatus: VALID <3>
19+
dataStreamStatus: VALID <1>
2320
----
24-
<1> Specify a path from the root directory (/) where the profile file is located.
25-
<2> Specify the container image that encapsulates the profile files.
26-
<3> Indicates whether the Compliance Operator was able to parse the content files.
21+
<1> Indicates whether the Compliance Operator was able to parse the content files.
2722

2823
[NOTE]
2924
====

modules/compliance-crd-scan-setting.adoc

Lines changed: 69 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,79 @@ By default, the Compliance Operator creates the following `ScanSetting` objects:
1414
.Example `ScanSetting` object
1515
[source,yaml]
1616
----
17-
apiVersion: compliance.openshift.io/v1alpha1
18-
kind: ScanSetting
19-
metadata:
20-
name: <name of the scan>
21-
autoApplyRemediations: false <1>
22-
autoUpdateRemediations: false <2>
23-
schedule: "0 1 * * *" <3>
24-
rawResultStorage:
25-
size: "2Gi" <4>
26-
rotation: 10 <5>
27-
roles: <6>
28-
- worker
29-
- master
17+
Name: default-auto-apply
18+
Namespace: openshift-compliance
19+
Labels: <none>
20+
Annotations: <none>
21+
API Version: compliance.openshift.io/v1alpha1
22+
Auto Apply Remediations: true
23+
Auto Update Remediations: true
24+
Kind: ScanSetting
25+
Metadata:
26+
Creation Timestamp: 2022-10-18T20:21:00Z
27+
Generation: 1
28+
Managed Fields:
29+
API Version: compliance.openshift.io/v1alpha1
30+
Fields Type: FieldsV1
31+
fieldsV1:
32+
f:autoApplyRemediations: <1>
33+
f:autoUpdateRemediations: <2>
34+
f:rawResultStorage:
35+
.:
36+
f:nodeSelector:
37+
.:
38+
f:node-role.kubernetes.io/master:
39+
f:pvAccessModes:
40+
f:rotation:
41+
f:size:
42+
f:tolerations:
43+
f:roles:
44+
f:scanTolerations:
45+
f:schedule:
46+
f:showNotApplicable:
47+
f:strictNodeScan:
48+
Manager: compliance-operator
49+
Operation: Update
50+
Time: 2022-10-18T20:21:00Z
51+
Resource Version: 38840
52+
UID: 8cb0967d-05e0-4d7a-ac1c-08a7f7e89e84
53+
Raw Result Storage:
54+
Node Selector:
55+
node-role.kubernetes.io/master:
56+
Pv Access Modes:
57+
ReadWriteOnce
58+
Rotation: 3 <3>
59+
Size: 1Gi <4>
60+
Tolerations:
61+
Effect: NoSchedule
62+
Key: node-role.kubernetes.io/master
63+
Operator: Exists
64+
Effect: NoExecute
65+
Key: node.kubernetes.io/not-ready
66+
Operator: Exists
67+
Toleration Seconds: 300
68+
Effect: NoExecute
69+
Key: node.kubernetes.io/unreachable
70+
Operator: Exists
71+
Toleration Seconds: 300
72+
Effect: NoSchedule
73+
Key: node.kubernetes.io/memory-pressure
74+
Operator: Exists
75+
Roles: <6>
76+
master
77+
worker
78+
Scan Tolerations:
79+
Operator: Exists
80+
Schedule: "0 1 * * *" <5>
81+
Show Not Applicable: false
82+
Strict Node Scan: true
83+
Events: <none>
3084
----
31-
3285
<1> Set to `true` to enable auto remediations. Set to `false` to disable auto remediations.
3386
<2> Set to `true` to enable auto remediations for content updates. Set to `false` to disable auto remediations for content updates.
34-
<3> Specify how often the scan should be run in cron format.
87+
<3> Specify the number of stored scans in the raw result format. The default value is `3`. As the older results get rotated, the administrator must store the results elsewhere before the rotation happens.
3588
<4> Specify the storage size that should be created for the scan to store the raw results. The default value is `1Gi`
36-
<5> Specify the amount of scans for which the raw results will be stored. The default value is `3`. As the older results get rotated, the administrator has to store the results elsewhere before the rotation happens.
89+
<5> Specify how often the scan should be run in cron format.
3790
+
3891
[NOTE]
3992
====

modules/compliance-crd-tailored-profile.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ With the `TailoredProfile` object, it is possible to create a new `Profile` obje
4747
+
4848
[source,yaml]
4949
----
50-
compliance.openshift.io/product-type: <scan type>
50+
compliance.openshift.io/product-type: Platform/Node
5151
----
5252
+
5353
[NOTE]

0 commit comments

Comments
 (0)