gpt4 book ai didi

kubernetes - 如何提供对服务帐户的访问以读取多个命名空间中的 pod?

转载 作者:行者123 更新时间:2023-12-02 12:04:49 29 4
gpt4 key购买 nike

我将介绍 Kubernetes 中的 RBAC。在我看来

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

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

最佳答案

您需要为 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

关于kubernetes - 如何提供对服务帐户的访问以读取多个命名空间中的 pod?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55232495/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com