限制 EKS 用户访问
restricting EKS user access
我正在尝试将新用户添加到 EKS 集群,然后授予访问权限。到目前为止,我可以通过编辑 configmap/aws-auth
(kubectl 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
用户的所有pods,有什么办法可以限制吗?
本质上,您想要的是定义集群角色并使用角色绑定将其应用到特定命名空间。使用集群角色(而不是角色)允许您跨命名空间重复使用它。使用角色绑定允许您针对特定命名空间而不是授予集群范围的权限。
我正在尝试将新用户添加到 EKS 集群,然后授予访问权限。到目前为止,我可以通过编辑 configmap/aws-auth
(kubectl 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
用户的所有pods,有什么办法可以限制吗?
本质上,您想要的是定义集群角色并使用角色绑定将其应用到特定命名空间。使用集群角色(而不是角色)允许您跨命名空间重复使用它。使用角色绑定允许您针对特定命名空间而不是授予集群范围的权限。