如何在ECS新UI中编辑自动扩缩容配置?
ECS服务自动扩缩容配置编辑方案(新版UI无入口、旧版切换按钮消失时)
手动跳转旧版控制台页面
直接修改浏览器地址栏路径:把新版ECS服务页面URL里的/v2/替换成/,比如原地址是https://console.aws.amazon.com/ecs/v2/clusters/xxx/services/xxx,修改后为https://console.aws.amazon.com/ecs/clusters/xxx/services/xxx,回车就能进入旧版UI,找到自动扩缩容的编辑选项。用AWS CLI命令直接修改
如果控制台操作走不通,可通过CLI完成配置:
先更新服务基础配置(示例):aws ecs update-service --cluster <你的集群名称> --service <你的服务名称> --desired-count <目标实例数> --capacity-provider-strategy capacityProvider=FARGATE,weight=1,base=0配置基于指标的自动扩缩容,需结合Application Auto Scaling:
先注册可扩缩目标:aws application-autoscaling register-scalable-target --service-namespace ecs --scalable-dimension ecs:service:DesiredCount --resource-id service/<集群名称>/<服务名称> --min-capacity 1 --max-capacity 10再添加扩缩容策略(需提前准备
scaling-policy.json文件):aws application-autoscaling put-scaling-policy --policy-name <自定义策略名> --service-namespace ecs --scalable-dimension ecs:service:DesiredCount --resource-id service/<集群名称>/<服务名称> --policy-type TargetTrackingScaling --target-tracking-scaling-policy-configuration file://scaling-policy.jsonscaling-policy.json示例内容(以CPU利用率为指标):{ "TargetValue": 70.0, "PredefinedMetricSpecification": { "PredefinedMetricType": "ECSServiceAverageCPUUtilization" }, "ScaleOutCooldown": 60, "ScaleInCooldown": 60 }通过Application Auto Scaling页面配置
直接打开AWS控制台的「Application Auto Scaling」服务,找到对应的ECS服务,在这里可以直接编辑自动扩缩容的目标容量、扩缩容策略等配置,不用依赖ECS旧版UI。
内容的提问来源于stack exchange,提问作者Anh
相关产品推荐
相关产品推荐

