18.2. 选择项目
您可以根据注解选择和/或标签选择来选择项目。例如,要根据注解选择项目,请运行以下命令:
$ oc create clusterquota for-user \ --project-annotation-selector openshift.io/requester=<user-name> \ --hard pods=10 \ --hard secrets=20
它创建以下 ClusterResourceQuota
对象:
apiVersion: v1 kind: ClusterResourceQuota metadata: name: for-user spec: quota: 1 hard: pods: "10" secrets: "20" selector: annotations: 2 openshift.io/requester: <user-name> labels: null 3 status: namespaces: 4 - namespace: ns-one status: hard: pods: "10" secrets: "20" used: pods: "1" secrets: "9" total: 5 hard: pods: "10" secrets: "20" used: pods: "1" secrets: "9"
此多项目配额文档使用默认的项目请求端点控制 <user-name> 请求的所有项目。您需要有 10 个 Pod 和 20 个 secret 的限制。
同样,若要根据标签选择项目,请运行以下命令:
$ oc create clusterresourcequota for-name \ 1 --project-label-selector=name=frontend \ 2 --hard=pods=10 --hard=secrets=20
它创建以下 ClusterResourceQuota
对象定义:
apiVersion: v1 kind: ClusterResourceQuota metadata: creationTimestamp: null name: for-name spec: quota: hard: pods: "10" secrets: "20" selector: annotations: null labels: matchLabels: name: frontend