shell - aws eks授权

2024-03-21
#!/bin/bash
users="xxx"
uid="123123463329"
cluster="dev-k8s"
region="ap-southeast-1"

for user in ${users}
do
    eksctl delete iamidentitymapping --cluster ${cluster} --region=${region} --arn arn:aws:iam::${uid}:user/${user}
    eksctl create iamidentitymapping --cluster ${cluster} --region=${region} --arn arn:aws:iam::${uid}:user/${user} --username ${user} --group system:masters --no-duplicate-arns
    eksctl get iamidentitymapping --cluster ${cluster} --region=${region}
done

自动生成kubeconfig至 ~/.kube/config

aws eks update-kubeconfig --region ap-southeast-1 --name bigdata-ai --alias aws-prod-ap-southeast-1 --profile prod --kubeconfig ~/.kube/config

# --alias aws-prod-ap-southeast-1 --profile prod --kubeconfig ~/.kube/config 为可选值
# --profile prod 为~/.aws/credentials中的AK别名
### 安装eksctl

https://github.com/eksctl-io/eksctl

### 安装aws cli

https://docs.aws.amazon.com/zh_cn/cli/latest/userguide/getting-started-install.html