GKE 有这个很棒的功能:
EKS 的默认设置很烦人,会导致糟糕的 UX(用户体验):
我想在 EKS 上重现 GKE 仅查看者 IAM 角色的功能,或尽可能接近它。我怎样才能做到这一点?
注意:以下是针对单租户集群的合理解决方案。
不要对多租户集群执行此操作。
2 步骤:
第1步:
kubectl edit cm aws-auth -n=kube-system
apiVersion: v1
data:
mapAccounts: '["111122223333"]' #<-- Your AWS Account
...
第2步:
kubectl apply -f all-authenticated-users-viewer.yaml
all-authenticated-users-viewer.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding # <-- apply rights to all namespaces
metadata:
name: all-authenticated-users-viewer
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: Group
name: system:authenticated # <-- authenticated = all kube identities & all that show in aws-auth configmap in kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: view #<-- acts as an aggregation role
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: enhanced-viewer
labels:
rbac.authorization.k8s.io/aggregate-to-view: "true" #<-- this will get merged into the "view" clusterrole
rules:
- apiGroups: [""]
verbs: ["get", "list", "watch"]
resources:
- podtemplates
- nodes
- persistentvolumes
- apiGroups: ["scheduling.k8s.io"]
verbs: ["get", "list", "watch"]
resources:
- priorityclasses
- apiGroups: ["apiregistration.k8s.io"]
verbs: ["get", "list", "watch"]
resources:
- apiservices
- apiGroups: ["coordination.k8s.io"]
verbs: ["get", "list", "watch"]
resources:
- leases
- apiGroups: ["node.k8s.io"]
verbs: ["get", "list", "watch"]
resources:
- runtimeclasses
- apiGroups: ["flowcontrol.apiserver.k8s.io"]
verbs: ["get", "list", "watch"]
resources:
- flowschemas
- prioritylevelconfigurations
- apiGroups: ["networking.k8s.io"]
verbs: ["get", "list", "watch"]
resources:
- ingressclasses
- apiGroups: ["storage.k8s.io"]
verbs: ["get", "list", "watch"]
resources:
- storageclasses
- volumeattachments
- csidrivers
- csinodes
- csistoragecapacities
- apiGroups: ["rbac.authorization.k8s.io"]
verbs: ["get", "list", "watch"]
resources:
- clusterroles
- clusterrolebindings
- roles
- rolebindings
- apiGroups: ["apiextensions.k8s.io"]
verbs: ["get", "list", "watch"]
resources:
- customresourcedefinitions
- apiGroups: ["admissionregistration.k8s.io"]
verbs: ["get", "list", "watch"]
resources:
- mutatingwebhookconfigurations
- validatingwebhookconfigurations