限制EKS用户访问

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

我正在尝试将新用户添加到EKS群集并提供访问权限。到目前为止,我只能通过编辑configmap/aws-authkubectl edit -n kube-system configmap/aws-auth)并添加新用户来添加用户

mapUsers: |
 - userarn: arn:aws:iam::123456789:user/user01
   username: user01
   groups:
     - system:masters

如何将用户添加到EKS集群并提供对特定命名空间的完全访问权限,但除此之外什么都没有?

我试图创建角色和角色绑定

---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  namespace: namespace1
  name: namespace1-user
rules:
- apiGroups: ["*"] 
  resources: ["*"]
  verbs: ["*"]


# This role binding allows "user01" to read pods in the "namespace1" namespace.
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: namespace1-user-role-binding
  namespace: namespace1
subjects:
- kind: User
  name: user01
  apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: Role
  name: namespace1-user

user01可以通过kubectl get pods --all-namespaces查看其他用户的所有pod,有什么方法可以限制这个吗?

kubernetes kubectl rbac
1个回答
2
投票

基本上您需要的是定义集群角色并使用角色绑定将其应用于特定名称空间。使用群集角色(而不是角色)允许您跨命名空间重用它。使用角色绑定可以定位特定的命名空间,而不是提供群集范围的权限。

© www.soinside.com 2019 - 2024. All rights reserved.