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.13.4. 创建安全性上下文约束
您可以使用 CLI 创建安全性上下文约束 (SCC)。
先决条件
-
您必须安装
oc
命令行。 -
您的帐户必须具有
cluster-admin
特权才能创建 SCC。
流程
在 JSON 或 YAML 文件中定义 SCC:
SecurityContextConstraints
对象定义Copy to Clipboard Copied! Toggle word wrap Toggle overflow 此外,您可以通过将
requiredDropCapabilities
字段设为所需的值,向 SCC 添加丢弃功能。所有指定的功能都将从容器中丢弃。例如,若要创建具有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 您可以在 Docker 文档中查看可能值的列表。
提示由于功能会传递到 Docker,您可以使用特殊值
ALL
来丢弃所有可能的功能。然后,运行
oc create
并传递文件来创建:oc create -f scc_admin.yaml
$ oc create -f scc_admin.yaml securitycontextconstraints "scc-admin" created
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 验证 SCC 已创建好:
oc get scc scc-admin
$ oc get scc scc-admin 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