Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I connect my autoscaling group to my ecs cluster?

In all tutorials for ECS you need to create a cluster and after that an autoscaling group, that will spawn instances. Somehow in all these tutorials the instances magically show up in the cluster, but noone gives a hint what's connecting the autoscaling group and the cluster.

my autoscaling group spawns instances as expected, but they just dont show up on my ecs cluster, who holds my docker definitions.

Where is the connection I'm missing?

like image 546
cari Avatar asked Feb 04 '16 13:02

cari


People also ask

Does ECS support Auto Scaling?

Automatic scaling is the ability to increase or decrease the desired count of tasks in your Amazon ECS service automatically. Amazon ECS leverages the Application Auto Scaling service to provide this functionality. For more information, see the Application Auto Scaling User Guide.

How do I connect to ECS cluster?

To connect to your container instanceOpen the Amazon ECS console at https://console.aws.amazon.com/ecs/ . Select the cluster that hosts your container instance. On the Cluster page, choose ECS Instances. On the Container Instance column, select the container instance to connect to.

How do I add a Auto Scaling group to my AMI?

To use a custom AMI with Amazon EC2 Auto Scaling, you must first create your AMI from a customized instance, and then use the AMI to create a launch template for your Auto Scaling group. You must have created a custom AMI in the same AWS Region where you plan to create the Auto Scaling group.


2 Answers

I was struggling with this for a while. The key to getting the instances in the autoscaling group associated with your ECS cluster is in the user data. When you are creating your launch config when you get to step 3 "Configure Details" hit the advanced tab and enter a simple bash script like the following for your user data.

#!/usr/bin/env bash echo ECS_CLUSTER=your_cluster_name >> /etc/ecs/ecs.config 

All the available parameters for agent configuration can be found here http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-config.html

like image 62
volker238 Avatar answered Sep 20 '22 17:09

volker238


An autoscaling group is not strictly associated to a cluster. However, an autoscaling group can be configured such that each instance launched registers itself into a particular cluster.

Registering an instance into a cluster is the responsibility of the ECS Agent running on the instance. If you're using the Amazon ECS-optimized AMI, the ECS Agent will launch when the instance boots and register itself into the configured cluster. However, you can also use the ECS Agent on other Linux AMIs by following the installation instructions.

like image 23
Samuel Karp Avatar answered Sep 22 '22 17:09

Samuel Karp