2

The company I work for uses Amazon ECS.

There are 5 or more production clusters configured there and there was some problem last week and AWS support team recommended us to change the ECS instance ami to an "Ubuntu ECS optimized" ami.

I'd like to go through all the clusters and replace the currently used ami with the ecs-optimized ami but I'm not sure what's the best way to approach this task.

There can be no downtime of any of the clusters.

How would you have done it?

Itai Ganot
  • 10,424
  • 27
  • 88
  • 143

1 Answers1

0
  1. Establish a new launch configuration with the new AMI for the ECS Cluster. Verify the new instances are online and associated with the cluster.
  2. Launch as many ECS container instances as you need. Ensure that your ECS task placement strategy is reflecting your intention (i.e., ensuring that the new tasks will be placed on the new instances. An example strategy would be spread(attribute:ecs.availability-zone), spread(instanceId). If in doubt, consult the documentation.
  3. Terminate the unwanted instances. Your strategy for that depends strongly on your service. Assuming you have a web application, you could add a lifecycle hook to your auto scaling group, that drains the unwanted ECS container instances. There is an interesting blog post concerning that issue, if you need ideas.

You probably want to try this in a safe staging environment first.

M. Glatki
  • 1,868
  • 1
  • 16
  • 33
  • I've configured a new staging cluster, autoscaling group and a new instance. The new instance appears in the auto scaling group but I'm having a problem registering the newly created instance/auto scaling group to the cluster... how is it done? – Itai Ganot Sep 06 '17 at 15:13
  • ECs uses Amazon ECS Container Agent, which needs some configuration (Can be done in the LaunchConfiguration). See here: http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-install.html Most likely, the existing cluster has a LaunchConfiguration that does exactly that. – M. Glatki Sep 06 '17 at 15:20