代码之家  ›  专栏  ›  技术社区  ›  simbo1905

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

  •  0
  • simbo1905  · 技术社区  · 8 年前

    我已经设置了一个角色为“视图”的合作者帐户。我现在想授予这个用户标记图像的能力 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标签 对用户的权限?

    谢谢!

    更新:

    我发现了一个预先存在的角色 registry-editor 在上面链接的“示例1”中列出了执行该任务的:

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

    我仍然很好奇,如果没有现成的角色,我将如何创建一个自定义角色。再次感谢!

    2 回复  |  直到 8 年前
        1
  •  1
  •   Will Gordon    8 年前

    请参阅Openshift文档 Creating a local role .

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

        2
  •  0
  •   simbo1905    8 年前

    有一个很好的例子 Helm template for openshift 哪个授权书写的? 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

    推荐文章