aws / amazon-ecs-cli

The Amazon ECS CLI enables users to run their applications on ECS/Fargate using the Docker Compose file format, quickly provision resources, push/pull images in ECR, and monitor running applications on ECS/Fargate.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_CLI.html
Other
1.76k stars 302 forks source link

Is there any plan to support the "Service Auto Scaling"? #205

Open linearregression opened 7 years ago

linearregression commented 7 years ago

http://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-auto-scaling.html

It is going to be very useful to have finer control of tasks. It does not a lot of samples or blog out there talking about this.

yinshiua commented 7 years ago

Thanks for your feedback.

ecs-cli has not integrate with service auto scaling yet. The current workaround for this is to use the ECS console or aws CLI.

vchan2002 commented 7 years ago

+1 for that feature, as it would be very useful to bring up a ECS service via one command. If so, can it function similar to how the latest enchancement of ecs-cli added support for ALB target groups via specifying its ARN? I think that's the most straightforward way of getting the right resource.

vchan2002 commented 7 years ago

Now that I looked into ECS auto scaling, and dived into the code, it's definitely a bit more complex...

My original thought was that auto scaling policies and what not are independent of ECS assets, like ALBs, target groups, and ELBs. However, each policy is tied tied to the ECS service in general...

Given that, trying to just to a flag aka how it's tied to an ELB or ALB might not make sense....

At this point, I'll work around this by having run the ECS CLI to add the autoscaling policy when the service is created/updated.

http://docs.aws.amazon.com/cli/latest/reference/application-autoscaling/put-scaling-policy.html

shatil commented 7 years ago

@yinshiua, same question here: do you expect this to be done via Cloudformation, or through API calls?

yinshiua commented 7 years ago

@shatil We will need to propose a design on how the implementation would be. I do think we should use CloudFormation considering that we will be making multiple API calls to setup Service Autos Scaling and we need a way to clean up the resources if on fails.

bver commented 6 years ago

Any plans w.r.t. this issue? I would like to have some ecs-cli command which could create a new autoscaling policy to the ECS's internal ASG resource (or assign somehow an existing service to external AS resources if it is simpler)

ecs-cli is very useful, thanks for it! Pavel

vchan2002 commented 6 years ago

I want to go ahead and revisit this... In my mind, this is the one piece that is missing from being able to use ecs-cli from end to end. Right now, I use ecs-cli to compose the task service and definitions, and as a workaround and I'll probably write a terraform module to get these resources to finish the resources necessary to setup autoscaling.

a. application auto scaling policy b. application auto scaling target c. Cloudwatch metric alarms to trigger the auto scaling policy.

Given that ecs-cli now supports using ecs-params.yaml to support non docker-compose standard parameters, can it be extended to do so?

adamjkeller commented 6 years ago

+1 to this feature request and comments by @vchan2002.

radiantone commented 5 years ago

Hi. What is the state of this issue? It's a pretty basic need.

anigetsin commented 5 years ago

Use the below command for setting up target autoscaling policy using aws cli

1. Enable scaling on the service you have using this command aws application-autoscaling register-scalable-target --resource-id "service/your-clustername/yourservice-name" \ --service-namespace ecs \ --scalable-dimension ecs:service:DesiredCount \ --min-capacity 1 --max-capacity 3 \ --role-arn "specify-correct-arn-here-for-ecsAutoscaleRole"

2. Create json file specifying your policy Example : cpu-80.json { "PolicyName": "targetTrackingCpu80", "ServiceNamespace": "ecs", "ResourceId": "service/your-cluster-name/your-service-name>", "ScalableDimension": "ecs:service:DesiredCount", "PolicyType": "TargetTrackingScaling", "TargetTrackingScalingPolicyConfiguration": { "TargetValue": 80, "PredefinedMetricSpecification": { "PredefinedMetricType": "ECSServiceAverageCPUUtilization" }, "ScaleOutCooldown": 60, "ScaleInCooldown": 60, "DisableScaleIn": false } }

3. Run this command to apply the json file

aws application-autoscaling put-scaling-policy --cli-input-json file://cpu-80.json

PettitWesley commented 5 years ago

@linearregression @vchan2002 @shatil @bver @adamjkeller @radiantone

Hey everyone, while the ECS CLI currently lacks support for this, we want to give some workarounds, in addition to the AWS CLI commands that @anigetsin showed:

Application autoscaling can be added after an ECS Service has been created. So our recommendation is to create your Service with the ECS CLI, and then add autoscaling using one of the following methods:

  1. ECS Console

The ECS Web UI has an easy-to-use wizard that can configure autoscaling on your service. Simply select your service in the Console, and click the update button to launch the wizard.

  1. AWS Cloud Developer Kit

The CDK example here demonstrates how to add autoscaling: https://awslabs.github.io/aws-cdk/refs/_aws-cdk_aws-ecs.html#task-autoscaling

  1. CloudFormation

The templates here show how to add autoscaling: https://containersonaws.com/architecture/autoscaling-service-containers/

Note that these template snippets don’t include the application autoscaling role. Here’s a snippet which you can use for that:

ApplicationAutoScalingRole:
    Type: AWS::IAM::Role
    Properties:
        AssumeRolePolicyDocument:
            Statement:
                - Effect: Allow
                  Principal:
                      Service:
                          - application-autoscaling.amazonaws.com
                  Action:
                      - sts:AssumeRole
        Path: "/"
        Policies:
            - PolicyName: ECSAggregatorScalingRole
              PolicyDocument:
                  Statement:
                      - Effect: Allow
                        Action:
                            - ecs:UpdateService
                            - ecs:DescribeServices
                            - application-autoscaling:*
                            - cloudwatch:DescribeAlarms
                            - cloudwatch:GetMetricStatistics
                        Resource: "*"
anigetsin commented 5 years ago

Thanks @PettitWesley I think that sums out all the options available for service auto scaling right now. I hope AWS brings this functionality in ecs-cli soon for us .

martyna-autumn commented 5 years ago

+1 for this feature

saksham commented 5 years ago

+1

jonni-larjomaa commented 5 years ago

+1 for making most of cloud infra, support for autoscaling is must, hope this will make it to the backlogs soon!

wmacdougall commented 5 years ago

+1

shrasool commented 4 years ago

+1

damian-keska commented 2 years ago

:+1: For this feature, it would be incredible useful to have this integrated into ecs-cli

leonarac commented 1 year ago

+1

imwexpex commented 1 year ago

This is needed for sure