如何提供对服务帐户的访问以读取多个名称空间中的窗格?

问题描述 投票:0回答:1

我要去Kubernetes的RBAC。在我看来

  • ServiceAccount可以绑定到命名空间(或)中的角色
  • ServiceAccount可以绑定到ClusterRole并具有群集范围的访问权限(所有命名空间?)

单个服务帐户(或用户)是否可能不具有群集范围的访问权限,但只能在命名空间的子集中具有只读访问权限?如果是这样,有人可以详细说明如何实现这一目标。谢谢!

kubernetes kubectl rbac
1个回答
1
投票

您需要为ServiceAccount应有权访问的每个命名空间中的每个命名空间创建一个RoleBinding。

有一个示例可以提供默认的ServiceAccount权限来读取development命名空间中的pod。

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: read-secrets
  namespace: development # This only grants permissions within the "development" namespace.
subjects:
- kind: ServiceAccount
  name: default
  namespace: kube-system
roleRef:
  kind: Role
  name: pod-reader 
  apiGroup: rbac.authorization.k8s.io
© www.soinside.com 2019 - 2024. All rights reserved.