如何通过命令行在aws ecs集群中按比例缩小/放大容器,我应该使用aws cli还是ecs-cli? [英] How to scale down/up containers in aws ecs cluster by command line, should I use aws cli or ecs-cli?

查看:141
本文介绍了如何通过命令行在aws ecs集群中按比例缩小/放大容器,我应该使用aws cli还是ecs-cli?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用EC2实例运行AWS ECS集群,并且我想要一个命令将任务扩展到1个正在运行的实例,然后在不需要时将其缩减到0.这应该破坏基础EC2实例以避免收费.我不使用Fargate,因为它不在免费套餐中.

I'm running AWS ECS cluster with EC2 instances and I want a command to scale up the tasks to 1 running instance and then after some time when I do not need it I want to scale it down to 0. This should destroy the underlying EC2 instance to avoid charges. I'm not using Fargate as it is not in free tier.

我目前正在使用什么来扩展到一个并开始运行它:

what I'm currently using to scale up to one and start running it:

ecs-cli scale --capability-iam --size 1 --cluster myEC2clusterName --region us-east-1
aws ecs run-task --cluster myEC2clusterName --region us-east-1 --task-definition myTaskDefinitionName:1 --count 1

我目前正在使用的缩小比例:

what I'm currently using to scale down:

ecs-cli scale --capability-iam --size 0 --cluster myEC2clusterName --region us-east-1

是否仅在aws cli中存在等效命令,而无需使用ecs-cli进行相同操作?

Is there an equivalent command only in aws cli without need to use ecs-cli to do the same?

推荐答案

是的,您可以调用 aws ecs update-service --cluster myEC2clusterName --region us-east-1 --service myServiceName --desired-count 0

我误解了这个问题.

您可以调用 SetDesiredCapacity API或使用 set-desired-capacity 命令调整EC2自动伸缩组的大小.

You can call the SetDesiredCapacity API or use the set-desired-capacity command to adjust the size of your EC2 auto scaling group.

这篇关于如何通过命令行在aws ecs集群中按比例缩小/放大容器,我应该使用aws cli还是ecs-cli?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆