6 points · by renaudg · 12y ago · 5 comments
I’m using Packer and Ansible to build a ready-to-go AMI in a few minutes from a base OS image.
But then, what tools do you use to automate the process of getting this AMI live ? Which entails : creating a new Launch Configuration with the AMI, pointing a standby autoscaling group to the new Launch config, ramping up the number of instances in it, start routing live traffic to it (likely by updating a Route53 alias entry to point to the right ELB), and finally scaling down the previously live group. Rinse and repeat.
I’m about to roll my own boto-based script to do that, but I'm sure this has to be a common pattern : anything out there already ?
As long as there is enough difference between the current number of instances in service and the maximum size of the ASG, existing instances won't be terminated until the new instances are passing healthchecks and the load balancer is sending them traffic. If the maximum has been reached, enough existing instances will be killed to provide room for the next batch of new instances.
Then there's a second playbook to bake the template into an AMI, update the launch configs and tell the autoscaling groups to use the new launch configs. For the latter two I had to write Ansible plugins (which the client might let me open source, once documented).
The idea being that when you do a deploy, the launch config is updated to use the new AMI ID. The old instances are terminated and the new ones popup in its place. You can play with the scaling options to set an update pause time. We can get a 0 sec downtime with this.
I have been doing continuous deployments baking ami's with asgard for a couple of years now and have had great results.