我知道当您希望服务帐户访问多个命名空间时,您可以为一个服务帐户分配多个角色,但我想知道当您向它分配多个集群范围内的集群角色时,它会如何表现。从我的角度来看,我认为它会选择其中之一,但我不确定。
权限纯粹是附加的(没有“拒绝”规则)。
这是我们必须记住的 kubernetes RBAC 角色的黄金法则。
“纯附加”意味着始终不允许撤销。
因此,“纯累加”意味着既不存在冲突,也不存在优先顺序。
例子:
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
# "namespace" omitted since ClusterRoles are not namespaced
name: pod-reader
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "watch", "list"]
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
# "namespace" omitted since ClusterRoles are not namespaced
name: node-reader
rules:
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "watch", "list"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: pod-reader
subjects:
- kind: User
name: abdennour
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
name: pod-reader
apiGroup: rbac.authorization.k8s.io
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: node-reader
subjects:
- kind: User
name: abdennour
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
name: node-reader
apiGroup: rbac.authorization.k8s.io
Run Code Online (Sandbox Code Playgroud)
正如您在此示例中所看到的,用户 Abdennour 最后应该拥有对节点和 Pod 的广泛读取访问权限。
| 归档时间: |
|
| 查看次数: |
7161 次 |
| 最近记录: |