|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * security/compliance_operator/compliance-operator-advanced.adoc |
| 4 | + |
| 5 | +:_content-type: PROCEDURE |
| 6 | +[id="compliance-custom-scc_{context}"] |
| 7 | += Creating a custom SCC for the Compliance Operator |
| 8 | + |
| 9 | +In some environments, you must create a custom Security Context Constraints (SCC) file to ensure the correct permissions are available to the Compliance Operator `api-resource-collector`. |
| 10 | + |
| 11 | +.Prerequisites |
| 12 | + |
| 13 | +* You must have `admin` privileges. |
| 14 | +
|
| 15 | +.Procedure |
| 16 | +. Define the SCC in a YAML file named `restricted-adjusted-compliance.yaml`: |
| 17 | ++ |
| 18 | +.`SecurityContextConstraints` object definition |
| 19 | +[source,yaml] |
| 20 | +---- |
| 21 | + allowHostDirVolumePlugin: false |
| 22 | + allowHostIPC: false |
| 23 | + allowHostNetwork: false |
| 24 | + allowHostPID: false |
| 25 | + allowHostPorts: false |
| 26 | + allowPrivilegeEscalation: true |
| 27 | + allowPrivilegedContainer: false |
| 28 | + allowedCapabilities: null |
| 29 | + apiVersion: security.openshift.io/v1 |
| 30 | + defaultAddCapabilities: null |
| 31 | + fsGroup: |
| 32 | + type: MustRunAs |
| 33 | + kind: SecurityContextConstraints |
| 34 | + metadata: |
| 35 | + name: restricted-adjusted-compliance |
| 36 | + priority: 30 <1> |
| 37 | + readOnlyRootFilesystem: false |
| 38 | + requiredDropCapabilities: |
| 39 | + - KILL |
| 40 | + - SETUID |
| 41 | + - SETGID |
| 42 | + - MKNOD |
| 43 | + runAsUser: |
| 44 | + type: MustRunAsRange |
| 45 | + seLinuxContext: |
| 46 | + type: MustRunAs |
| 47 | + supplementalGroups: |
| 48 | + type: RunAsAny |
| 49 | + users: |
| 50 | + - system:serviceaccount:openshift-compliance:api-resource-collector <2> |
| 51 | + volumes: |
| 52 | + - configMap |
| 53 | + - downwardAPI |
| 54 | + - emptyDir |
| 55 | + - persistentVolumeClaim |
| 56 | + - projected |
| 57 | + - secret |
| 58 | +---- |
| 59 | +<1> The priority of this SCC must be higher than any other SCC that applies to the `system:authenticated` group. |
| 60 | +<2> Service Account used by Compliance Operator Scanner pod. |
| 61 | +
|
| 62 | +. Create the SCC: |
| 63 | ++ |
| 64 | +[source,terminal] |
| 65 | +---- |
| 66 | +$ oc create -f restricted-adjusted-compliance.yaml |
| 67 | +---- |
| 68 | ++ |
| 69 | +.Example output |
| 70 | +[source,terminal] |
| 71 | +---- |
| 72 | +securitycontextconstraints.security.openshift.io/restricted-adjusted-compliance created |
| 73 | +---- |
| 74 | +
|
| 75 | +.Verification |
| 76 | +. Verify the SCC was created: |
| 77 | ++ |
| 78 | +[source,terminal] |
| 79 | +---- |
| 80 | +$ oc get scc restricted-adjusted-compliance |
| 81 | +---- |
| 82 | ++ |
| 83 | +.Example output |
| 84 | +[source,terminal] |
| 85 | +---- |
| 86 | +NAME PRIV CAPS SELINUX RUNASUSER FSGROUP SUPGROUP PRIORITY READONLYROOTFS VOLUMES |
| 87 | +restricted-adjusted-compliance false <no value> MustRunAs MustRunAsRange MustRunAs RunAsAny 30 false ["configMap","downwardAPI","emptyDir","persistentVolumeClaim","projected","secret"] |
| 88 | +---- |
0 commit comments