After having read that article, I decided to write a Capistrano gem in order to automatise this blue/green deployment procedure (Yes, I’m a Rails dev, and I like to “just” call deploy, and wait to get it done well).
I have implemented exactly (as far as I can see) what’s written in that article, and the deployment is working, but with 5 seconds downtime when redeploying the load balancer.
(Here is the Github repo: https://github.com/YourCursus/capistrano-docker-cloud).
To summarise what’s done:
- After having checked some required information I’m looking for a stack with the stage name (conversion over configuration). Here I’m deploying with
cap staging docker_cloud:deploy so the gem is looking for a stack named ‘staging’.
- The gem check in this stack that no other service is running the image and tag we’re going to deploy
- Then the gem check if there is a load balancer in the stack (jn order to finish the deployment, otherwise it make no sense)
- Now starts the deployment: the gem creates a new service using the docker image name (without the namespace) then the tag with dots and underscores replaced by hyphens. The service configuration is copied from the service already existing running the same image but with a different tag (otherwise it uses the default values).
- The gem starts the servie
- The gem waits until the service is in the “Running” state, and then waits until it gets a 200 from all the containers of the service
- Finally the gem update the load balancer links and redeploy
And here is the moment when it breaks, when redeploying the load balancer.
Can you please tell me what am I doing wrong which causes this downtime ?