riverfall
riverfall

Reputation: 840

jenkins scalable-amazon-ecs scale from zero

In Jenkins there are two similar plugins available:

enter image description here

Both are linked to the same Jenkins wiki page

I haven't found any documentation for the scalable version of the plugin and I have the following question:

Is it possible to add ECS instances in cluster from 0(none) to 1 using this plugin? I want to have active ECS instances only when there are jobs to be done.

I will appreciate any help.

Upvotes: 1

Views: 870

Answers (2)

Andrew S.
Andrew S.

Reputation: 21

Try to uninstall these plugins and compile ecs-slave plugin manually from the branch autoscaling https://github.com/cbamelis/amazon-ecs-plugin

Upvotes: 1

riverfall
riverfall

Reputation: 840

I found a workaround to scale out the number of ECS instances from zero. I created a new job with the following shell code:

result=$(aws ecs list-container-instances --cluster ${cluster-name} | grep -c arn:aws:ecs:${aws-region}) || true
if [ "$result" = '0' ]
    then aws autoscaling set-desired-capacity --auto-scaling-group-name ${asg-name} --desired-capacity 1
else 
    echo "Container already exists"
fi

replace variables ${cluster-name}, ${aws-region}, ${asg-name} with actual values

This job increases the number of ECS VMs to 1 if it was 0.

Scaling in can be done using Cloudwatch alarm and Autoscaling policy.

Upvotes: 0

Related Questions