AWS EKS 安装Auto Scaler
- 为你的node group 加上 以下的tag
tag title | tag value |
k8s.io/cluster-autoscaler/<cluster-name> | owned |
k8s.io/cluster-autoscaler/enabled | TRUE |
2. 创建集群IAM OIDC身份提供商, 如果你已经创建了就无需再创建
eksctl utils associate-iam-oidc-provider --cluster yourClusterName --approve
3. 把以下这个policy 存在你的本机,名为autoscaler.json
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:DescribeLaunchConfigurations",
"autoscaling:DescribeTags",
"autoscaling:SetDesiredCapacity",
"autoscaling:TerminateInstanceInAutoScalingGroup",
"ec2:DescribeLaunchTemplateVersions"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
4. 使用aws cli 根于步骤3的文件创建policy
aws iam create-policy \
--policy-name AmazonEKSClusterAutoscalerPolicy \
--policy-document file://cluster-autoscaler-policy.json
5. 创建service account 把 刚刚创建的policy给关联起来
eksctl create iamserviceaccount \
--cluster=eks集群名 \
--namespace=kube-system \
--name=cluster-autoscaler \
--attach-policy-arn=arn:aws:iam::账号号码:policy/AmazonEKSClusterAutoscalerPolicy \
--override-existing-serviceaccounts \
--approve
部署Auto Scaler
6. 跑这个command以下载部署的yaml文件
curl -o cluster-autoscaler-autodiscover.yaml https://raw.githubusercontent.com/kubernetes/autoscaler/master/cluster-autoscaler/cloudprovider/aws/examples/cluster-autoscaler-autodiscover.yaml
7. 更改这个yaml文件把YOUR CLUSTER NAME改成你的集群名
8. 配置kubectl以访问EKS
aws eks --region api-southeast-1 update-kubeconfig --name YourClusterName
9. 使用kubectl 部署yaml文件
kubectl apply -f cluster-autoscaler-autodiscover.yaml
参考文档
https://docs.amazonaws.cn/eks/latest/userguide/cluster-autoscaler.html
https://www.youtube.com/watch?v=u0fTPemh9L0&t=1538s
Facebook评论