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.12.4. Creating security context constraints
You can create security context constraints (SCCs) by using the OpenShift CLI (oc
).
Prerequisites
-
Install the OpenShift CLI (
oc
). -
Log in to the cluster as a user with the
cluster-admin
role.
Procedure
Define the SCC in a YAML file named
scc_admin.yaml
:SecurityContextConstraints
object definitionCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optionally, you can specify drop capabilities for an SCC by setting the
requiredDropCapabilities
field with the desired values. Any specified capabilities are dropped from the container. For example, to create an SCC with theKILL
,MKNOD
, andSYS_CHROOT
required drop capabilities, add the following to the SCC object:requiredDropCapabilities: - KILL - MKNOD - SYS_CHROOT
requiredDropCapabilities: - KILL - MKNOD - SYS_CHROOT
Copy to Clipboard Copied! Toggle word wrap Toggle overflow CRI-O supports the same list of capability values that are found in the Docker documentation.
Create the SCC by passing in the file:
oc create -f scc_admin.yaml
$ oc create -f scc_admin.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
securitycontextconstraints "scc-admin" created
securitycontextconstraints "scc-admin" created
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that the SCC was created:
oc get scc scc-admin
$ oc get scc scc-admin
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME PRIV CAPS SELINUX RUNASUSER FSGROUP SUPGROUP PRIORITY READONLYROOTFS VOLUMES scc-admin true [] RunAsAny RunAsAny RunAsAny RunAsAny <none> false [awsElasticBlockStore azureDisk azureFile cephFS cinder configMap downwardAPI emptyDir fc flexVolume flocker gcePersistentDisk gitRepo glusterfs iscsi nfs persistentVolumeClaim photonPersistentDisk quobyte rbd secret vsphere]
NAME PRIV CAPS SELINUX RUNASUSER FSGROUP SUPGROUP PRIORITY READONLYROOTFS VOLUMES scc-admin true [] RunAsAny RunAsAny RunAsAny RunAsAny <none> false [awsElasticBlockStore azureDisk azureFile cephFS cinder configMap downwardAPI emptyDir fc flexVolume flocker gcePersistentDisk gitRepo glusterfs iscsi nfs persistentVolumeClaim photonPersistentDisk quobyte rbd secret vsphere]
Copy to Clipboard Copied! Toggle word wrap Toggle overflow