kubernetes - 如何配置卷(第二部分)?
问题描述
我正在尝试配置 RBAC,以便我可以配置卷。这是此(如何正确地为 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
解决方案
RBAC 身份验证规则配置有 K8s 资源,可分为两组:
Roles
其中ClusterRole
指定可以对哪些资源执行哪些动词/动作。RoleBindings
并将ClusterRoleBindings
上述角色绑定到特定的用户、组或 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 部分:使用 RBAC 授权
推荐阅读
- r - 下载最终数据表并在 shinydashboard 中绘图
- firebase - 通过 Cloud Functions 对用户进行身份验证
- python - 如何在 Django 模板中呈现 ChoiceField 选项
- python - 为什么内部标签中的文本被忽略,如何解决?
- javascript - 在Angular中重新加载时如何设置超时不会重复
- stata - 如何在stata中使用asdoc命令获取值标签作为表标题?
- microsoft-graph-api - Microsoft Graph Beta 端点元数据是否因名称冲突而无效?
- python - Conv Autoencoder 层级数
- flutter - socket 、 socketio 和 websockets 之间的区别
- c++ - 将元素添加到列表