如何授予用户在 OpenShift Online Pro 中标记图像的能力?

How do I grant a user the ability to tag images in OpenShift Online Pro?

我已经设置了角色 "view" 的协作者帐户。我现在想授予此用户使用 oc tag 标记图像的能力。

遵循 these 说明,我有:

oc get clusterrole view -o yaml > role_edittags.yaml
# 1. Update kind: ClusterRole to kind: Role
# 2. Update name: view to name: edittags
# 3. Remove resourceVersion, selfLink, uid, and creationTimestamp
# 4. split up the section with {imagestreamimages,imagestreammappings,imagestreams,imagestreamtags} into two sections:
- apiGroups:
  - image.openshift.io
  - ""
  attributeRestrictions: null
  resources:
  - imagestreamimages
  - imagestreammappings
  - imagestreams
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - image.openshift.io
  - ""
  attributeRestrictions: null
  resources:
  - imagestreamtags
  verbs:
  - get
  - list
  - watch
  - create
  - update
  - patch
  - deletecollection

然后我 oc project 进入我想授予角色的项目并导入它:

$ oc create -f role_edittags.yaml role "edittags" created

当我尝试将其授予用户时出现错误:

$ oc policy add-role-to-user edittags myuser Error from server (NotFound): rolebindings.authorization.openshift.io "edittags" not found

如何向用户授予 oc tag 权限?

谢谢!

更新:

我在上面 link 的 "example 1" 中找到了一个预先存在的角色 registry-editor 来完成这项工作:

$ oc policy add-role-to-user registry-editor myuser role "registry-editor" added: "myuser"

我仍然很想知道如果没有现成的自定义角色,我该如何创建自定义角色。再次感谢!

请参阅 Creating a local role 上的 OpenShift 文档。

具体来说,要将用户绑定到 local 角色,您需要将 --role-namespace 指定到 oc policy add-role-to-user 命令。

Helm template for openshift which grants write access to configmaps中有一个很好的例子。所有默认角色都显示为 oc describe clusterPolicy default,这是一个很好的起点,可以编写一个类似于现有角色的新角色。在我的例子中,现有角色 registry-editor 是我需要通过标记图像和从 RedHat 容器目录中提取上游补丁来自动进行促销的角色。

更新:

以下是如何创建可以启动 openshift 构建的本地角色:

oc create role buildinstantiate --verb=create --resource=buildconfigs.build.openshift.io/instantiate -n hubot

oc adm policy add-role-to-user buildinstantiate myuser --role-namespace=hubot -n hubot