本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
管理 IAM 使用者和角色
注意
AWS 建議EKS Pod 身分關聯從 ConfigMap migraitng 至 aws-auth
。
EKS 叢集使用 IAM 使用者和角色來控制對叢集的存取。規則會在組態映射中實作
使用 CLI 命令編輯 ConfigMap
稱為 aws-auth
。 eksctl
提供命令來讀取和編輯此組態映射。
取得所有身分映射:
eksctl get iamidentitymapping --cluster <clusterName> --region=<region>
取得符合 arn 的所有身分映射:
eksctl get iamidentitymapping --cluster <clusterName> --region=<region> --arn arn:aws:iam::123456:role/testing-role
建立身分映射:
eksctl create iamidentitymapping --cluster <clusterName> --region=<region> --arn arn:aws:iam::123456:role/testing --group system:masters --username admin
刪除身分映射:
eksctl delete iamidentitymapping --cluster <clusterName> --region=<region> --arn arn:aws:iam::123456:role/testing
注意
除非--all
指定 ,否則上述命令會刪除單一映射 FIFO,在這種情況下會移除所有相符項目。如果找到符合此角色的更多映射,將會發出警告。
建立帳戶映射:
eksctl create iamidentitymapping --cluster <clusterName> --region=<region> --account user-account
刪除帳戶映射:
eksctl delete iamidentitymapping --cluster <clusterName> --region=<region> --account user-account
使用 ClusterConfig 檔案編輯 ConfigMap
也可以在 ClusterConfig 中指定身分映射:
--- apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: cluster-with-iamidentitymappings region: us-east-1 iamIdentityMappings: - arn: arn:aws:iam::000000000000:role/myAdminRole groups: - system:masters username: admin noDuplicateARNs: true # prevents shadowing of ARNs - arn: arn:aws:iam::000000000000:user/myUser username: myUser noDuplicateARNs: true # prevents shadowing of ARNs - serviceName: emr-containers namespace: emr # serviceName requires namespace - account: "000000000000" # account must be configured with no other options nodeGroups: - name: ng-1 instanceType: m5.large desiredCapacity: 1
eksctl create iamidentitymapping -f cluster-with-iamidentitymappings.yaml