Jan 14, 2016

Upgrading an Amazon ECS cluster to Docker 1.9

As announced yesterday, Amazon ECS now supports Docker 1.9 (1.9.1 actually). Woohoo.

In order to benefit from this update, a cluster must use the latest ECS-optimized Amazon Machine Image (AMI), which embeds Docker 1.9.1 and ECS Agent version 1.7.1. As a sidenote, if you want to pull Docker images from Amazon ECR, your agent version must be at least 1.7.0, so that's probably another reason to upgrade :)

The AMI you're looking for is amzn-ami-2015.09.d-amazon-ecs-optimized. The AMI id varies from one region to the next, here's the full table. For eu-west-1, the id is ami-03238b70

Here's a simple way to upgrade a cluster:

1) Go to the EC2 console and locate the Launch Configuration used by the Auto Scaling group for your ECS instances.

2) Click "Copy Launch Configuration" to create a copy.

3) Click "Edit AMI" and using the AMI id from the table above, search and select the new AMI.

4) Leave everything else unchanged and create the launch configuration. You should now see something similar to this:


5) Edit the Auto Scaling group. The first step is to replace the old launch configuration with the new one


Let's say you have 5 ECS instances in the cluster. The next step is then to start 5 new ECS instances in order to replace the older ones while providing enough capacity for all your tasks: edit 'Desired' (and possibly 'Max') to 10 and save.

Within a few minutes, you will have 10 instances running:


6) Deregister the old instances. In the ECS console, go through each one of the old instances and click 'Deregister' to remove them from the cluster. At this point, the ECS scheduler will launch tasks as needed on the new instances. Don't have to worry about your containers, they will quickly find a new home :)

7) Terminate the old instances. In the EC2 console, select all the old instances and terminate them.

8) Resize the Auto Scaling group. Go back to the Auto Scaling group and set the right values for 'Desired' and 'Max'.

Job done. This should be a quick and seamless operation. Happy to hear your feedback!

No comments:

Post a Comment