【问题标题】:How can I provision a volume (part II)?如何配置卷(第二部分)?
【发布时间】:2020-11-24 16:30:57
【问题描述】:

我正在尝试配置 RBAC,以便我可以配置卷。这是此 (How can I properly provision a volume for argo?) 线程的后续。添加角色将错误从“无法获取资源”更改为“无法创建资源”。

我现在认为是 Kubernetes 的问题,但还是不明白如何解决。

错误:

Error from server (Forbidden): error when creating "/tmp/manifest.yaml": persistentvolumeclaims is forbidden: User "system:serviceaccount:argo:argo" cannot create resource "persistentvolumeclaims" in API group "" in the namespace "argo" 

角色.yaml

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: workflow
  namespace: argo
rules:
- apiGroups:
  - ""
  resources:
  - pods
  verbs:
  - get
  - list
  - watch
  - create
  - update
  - patch
  - delete
- apiGroups:
  - ""
  resources:
  - pods/log
  verbs:
  - get
  - list
  - watch
  - create
  - update
  - patch
  - delete
- apiGroups:
  - ""
  resources:
   - persistentvolumeclaims
  verbs:
  - get
  - list
  - watch
  - create
  - update
  - patch
  - delete

【问题讨论】:

    标签: kubernetes volume persistent-volume-claims


    【解决方案1】:

    RBAC auth 规则配置有 K8s 资源,可以分为两组:

    • RolesClusterRole 指定哪些动词/动作可以 在哪些资源上执行。
    • RoleBindingsClusterRoleBindings 将上述角色绑定到 特定用户、组或 ServiceAccounts。

    在您的情况下,您成功创建了Roles,但您缺少的是RoleBindings,简而言之,谁能执行您已经指定的操作。

    可以使用 yaml 文件创建角色绑定:

    apiVersion: rbac.authorization.k8s.io/v1
    kind: RoleBinding
    metadata:
      name: workflow-argo
      namespace: argo
    subjects:
    # You can specify more than one "subject"
    - kind: User
      name: jane # "name" is case sensitive
      apiGroup: rbac.authorization.k8s.io
    roleRef:
      # with "roleRef" you specify the binding to a Role / ClusterRole
      kind: Role 
      name: workflow # here you have to reference the name of your Role
      apiGroup: rbac.authorization.k8s.io
    

    或使用命令:

    kubectl create rolebinding workflow-argo --clusterrole=workflow --user=jane --namespace=argo
    

    欲了解更多信息,请查看 K8s 部分:Using RBAC Authorization

    【讨论】:

      猜你喜欢
      • 2022-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-23
      • 2013-06-24
      • 1970-01-01
      • 2010-12-31
      • 2013-05-31
      相关资源
      最近更新 更多