kubernetes - 一个 Kubernetes 仪表板,用于多个选定的命名空间
问题描述
我们的集群中有多个命名空间。管理员可以通过 ClusterRole 访问所有命名空间。但是,用户将被授予访问相应命名空间的权限。
假设用户 A 被授予对命名空间 B、C 和 D 的访问权限。
因此,用户 A 使用服务帐户和 RoleBinding 在命名空间 B 中部署仪表板。用户将能够看到命名空间 B 中的所有应用程序。但是,我们如何授予对该仪表板的访问权限,以便一个仪表板将列出 3 个命名空间以查看相应的应用程序?
解决方案
在当前版本的Kubernetes中,不同的用户可以管理不同的命名空间。您需要了解RBAC的工作原理以及如何使用它来管理多个仪表板。
概念草案:您需要创建规则、角色和授予权限(集群范围和所有命名空间),然后进行角色绑定。它可用于授予对任何特定命名空间或所有命名空间中资源的读取访问权限。
例如,这里是如何将用户“jane”绑定到默认命名空间并将用户“dave”绑定到开发团队。您可以在两个命名空间中提供 Dashboard 以授予单个用户对它们的访问权限。
# This role binding allows "jane" to read pods in the "default" namespace.
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: read-pods
namespace: default
subjects:
- kind: User
name: jane # Name is case sensitive
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: Role #this must be Role or ClusterRole
name: pod-reader # this must match the name of the Role or ClusterRole you wish to bind to
apiGroup: rbac.authorization.k8s.io
# This role binding allows "dave" to read secrets in the "development" namespace.
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: read-secrets
namespace: development # This only grants permissions within the "development" namespace.
subjects:
- kind: User
name: dave # Name is case sensitive
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
name: secret-reader
apiGroup: rbac.authorization.k8s.io
推荐阅读
- c# - 我可以将 String 的一维数组转换为 Datacolumn 的一维数组吗?
- mysql - Laravel Eloquent 中的多级条件查询
- python - 替换数据框Python列中的多个值
- content-management-system - Ghost CMS创建的博客的MySQL数据库设置
- arduino - 在哪里输入 5*5 按键矩阵的代码来控制 5*5 Led-Matrix 以正方形的形状点亮
- python - XPaths:选择特定元素
- asp.net-core - 使用 .net Framework 4.6.1 将 Microsoft Dynamics GP 2018 与 eConnect 18 连接时,对象引用未设置为对象实例
- javascript - React 本机内置 qrcode 生成器不起作用
- reactjs - 如何在reacjs中获取类名?
- reactjs - 如何在 reactjs 应用程序中实现条码扫描器?