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.15.4. 创建安全性上下文约束
				您可以使用 OpenShift CLI(oc)创建安全性上下文约束(SCC)。
			
先决条件
- 
						安装 OpenShift CLI (oc) 。
- 
						以具有 cluster-admin角色的用户身份登录集群。
流程
- 在名为 - scc_admin.yaml的 YAML 文件中定义 SCC:- SecurityContextConstraints对象定义- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 另外,您可以通过将 - requiredDropCapabilities字段设为所需的值来丢弃 SCC 的特定功能。所有指定的功能都会从容器中丢弃。要丢弃所有的能力,请指定- ALL。例如,要创建一个丢弃- KILL、- MKNOD和- SYS_CHROOT功能的 SCC,请将以下内容添加到 SCC 对象中:- requiredDropCapabilities: - KILL - MKNOD - SYS_CHROOT - requiredDropCapabilities: - KILL - MKNOD - SYS_CHROOT- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 注意- 您不能列出 - allowedCapabilities和- requiredDropCapabilities中的功能。- CRI-O 支持 Docker 文档中找到的相同功能值列表。 
- 通过传递文件来创建 SCC: - oc create -f scc_admin.yaml - $ oc create -f scc_admin.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 输出示例 - securitycontextconstraints "scc-admin" created - securitycontextconstraints "scc-admin" created- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
验证
- 验证 SCC 已创建好: - oc get scc scc-admin - $ oc get scc scc-admin- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 输出示例 - 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