如何在gke中为用户授予名称空间访问权限?

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

我有一个带有多个名称空间的google kubernetes引擎集群。这些名称空间中的每一个上都部署了不同的应用程序。是否可以仅授予用户对单个名称空间的完全访问权限?

kubernetes google-cloud-platform namespaces google-kubernetes-engine access
2个回答
0
投票

是的,Kubernetes具有与Cloud IAM集成的内置RBAC系统,因此您可以控制GCP用户对单个群集和名称空间的访问。

  1. 创建Role
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  namespace: YOUR_NAMESPACE
  name: ROLE_NAME
rules:
- apiGroups: [""] # "" indicates the core API group
  resources: ["pods"]
  verbs: ["get", "watch", "list"]
  1. 创建RoleBinding
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: ROLE_NAME-binding
  namespace: YOUR_NAMESPACE
subjects:
# GCP user account
- kind: User
  name: [email protected]

参考


0
投票

您可以在所选名称空间中使用Rolebinding将用户绑定到集群管理员角色。如documentation中所指定,cluster-admin:

允许超级用户访问权对任何资源执行任何操作。什么时候用于ClusterRoleBinding中,它可以完全控制每个群集和所有命名空间中的资源。当用于RoleBinding,它可以完全控制角色绑定的名称空间,包括名称空间本身。

例如:

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: example
  namespace: yournamespace
subjects:
- kind: User
  name: example-user
  apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io
© www.soinside.com 2019 - 2024. All rights reserved.