Pepster
Pepster

Reputation: 2166

How to replace ECS cluster instances without downtime or reduced redundancy?

I currently have a try-out environment with ~16 services divided over 4 micro-instances. Instances are managed by an autoscaling group (ASG). When I need to update the AMI of my cluster instances, currently I do:

  1. Create new launch config, edit ASG with new launch config.
  2. Detach all instances with replacement option from the ASG and wait until the new ones are listed in the cluster instance list.
  3. MANUALLY find and deregister the old instances from the ECS cluster (very tricky)
  4. Now the services are killed by ECS due to deregistering the instances :(
  5. Wait 3 minutes until the services are restarted on the new instances
  6. MANUALLY find the EC2 instances in the EC2 instance list and terminate them (be very very careful not to terminate the new ones).

With this approach I have about 3 minutes of downtime and I shiver from the idea to do this in production envs.. Is there a way to do this without downtime but keeping the overall amount of instance the same (so without 200% scaling settings etc.).

Upvotes: 1

Views: 1465

Answers (1)

briancurt
briancurt

Reputation: 132

You can update the Launch Configuration with the new AMI and then assign it to the ASG. Make sure to include the following in the user-data section:

echo ECS_CLUSTER=your_cluster_name >> /etc/ecs/ecs.config

Then terminate one instance at a time, and wait until the new one is up and automatically registered before terminating the next.

This could be scriptable to be automated too.

Upvotes: 1

Related Questions