Autoscaling EKS with Rancher

在 AWS 上,Cluster Autoscaler 使用 Amazon EC2 Auto Scaling Groups 来管理 Node group

Cluster Autoscaler 以 deployment 的方式部署

推荐使用 Service Accounts 来控制权限

创建 IAM policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "elasticloadbalancing:ModifyListener",
                "elasticloadbalancing:DetachLoadBalancerFromSubnets",
                "elasticloadbalancing:ConfigureHealthCheck",
                "elasticloadbalancing:RegisterTargets",
                "autoscaling:DescribeLaunchConfigurations",
                "autoscaling:*",
                "elasticloadbalancing:DeleteLoadBalancer",
                "elasticloadbalancing:DescribeLoadBalancers",
                "elasticloadbalancing:CreateListener",
                "elasticloadbalancing:DescribeListeners",
                "autoscaling:DescribeAutoScalingGroups",
                "ec2:CreateInternetGateway",
                "kms:*",
                "elasticloadbalancing:DescribeLoadBalancerPolicies",
                "elasticloadbalancing:ApplySecurityGroupsToLoadBalancer",
                "tag:*",
                "elasticloadbalancing:DeregisterInstancesFromLoadBalancer",
                "elasticloadbalancing:RegisterInstancesWithLoadBalancer",
                "elasticloadbalancing:CreateLoadBalancerPolicy",
                "elasticloadbalancing:SetLoadBalancerPoliciesForBackendServer",
                "elasticloadbalancing:CreateLoadBalancer",
                "elasticloadbalancing:AttachLoadBalancerToSubnets",
                "autoscaling:DescribeTags",
                "elasticloadbalancing:CreateTargetGroup",
                "cloudformation:*",
                "elasticloadbalancing:*",
                "autoscaling-plans:*",
                "elasticloadbalancing:DeleteTargetGroup",
                "elasticloadbalancing:CreateLoadBalancerListeners",
                "iam:*",
                "elasticloadbalancing:DescribeLoadBalancerAttributes",
                "elasticloadbalancing:SetLoadBalancerPoliciesOfListener",
                "elasticloadbalancing:AddTags",
                "elasticloadbalancing:DescribeTargetHealth",
                "elasticloadbalancing:DescribeTargetGroups",
                "elasticloadbalancing:DeleteLoadBalancerListeners",
                "ec2:*",
                "eks:*",
                "elasticloadbalancing:ModifyLoadBalancerAttributes",
                "elasticloadbalancing:ModifyTargetGroup",
                "elasticloadbalancing:DeleteListener"
            ],
            "Resource": "*"
        }
    ]
}

创建新用户并且赋予我们创建的 policy

通过rancher来创建一个eks

这里可以直接设置 ASG

等待片刻

下面是一个测试

先修改一下按cpu使用率扩容

希望如果cpu占用率持续超过 10% 连续60秒就 扩容

就在我修改这个配置之后,节点数从 2 自动变成了 1

用wrk来点cpu压力

可以看到启动了 4 个新节点

Send a Message