In my prior posts, I’ve written about how to ensure a highly resilient workloads using Docker, Rancher, and various open source tools. For this post, I will build on this prior knowledge, and to setup an AWS infrastructure for Rancher with some commonly used tools. If you check out the repository here, you should be able to follow along and setup the same infrastructure.
The final output of our AWS infrastructure will look like the following picture:
Note: this is Part 4 in a series on building highly resilient workloads. Parts 1, 2, and 3 are available already online.
In Part 4 of this series on running resilient workloads with Docker and Rancher, we take a look at service updates. Generally, service updates are where the risk of downtime is the highest. It doesn’t hurt to have a grasp of how deployments work in Rancher and the options available within.
For this post, instead of focusing on how to setup a continuous deployment/integration pipeline, we’ll instead focus on experimenting and learning with upgrades using rancher-compose files, and reference the great chain of articles by the awesome bloggers. We will skim over the Rancher CI/CD ebook for now, and sprinkle in enough theory to get us start using Rancher upgrades comfortably. Read more
In part one of our series, we left off with constructing a rudimentary build and deployment pipeline. Containers are no longer deployed by typing Docker commands from memory while logged into servers. Image builds have been automated via our Jenkins server. We have wrapped the Docker commands with a bash script, stored and versioned in GitHub. We are taking steps towards continuous deployment by incrementally improving the existing process. However, there are still some pain points we need to address, in this post we’ll look at how we used Docker Compose and Ansible to improve on this design.
To deploy an image, an engineer is required to log into a server and run our Docker wrapper script from the shell. This isn’t good. It also requires the developers to wait. Neither party wins this way (as an engineer, how many times have you been interrupted to do something you know could easily be automated?). There is also no visibility into the deployment process since each deployment is executed from an SSH session on an operator laptop.
If you remember, our deployment script looks like the snippet below:
Over the last year I’ve been using Rancher with Ansible, and have found that using the two together can be incredibly useful. If you aren’t familiar with Ansible, it is a powerful configuration management tool which can be used to manage servers remotely without a daemon or agent running on the host. Instead, it uses SSH to connect with hosts, and applies tasks directly on the machines. Because of this, as long as you have SSH access to the host, (and Python) running on the host, you will be able to use Ansible to manage hosts remotely. You can find detailed documentation for Ansible on the company’s website..
In this post, I will be using Ansible with Docker to automate the build out of a simple wordpress environment on a Rancher deployment. Specifically, I will include the following steps:
Installing Docker on my hosts using Ansible.
Setting up a fresh Rancher installation using Ansible.
Registering hosts with Rancher using Ansible.
Deploying the Application containers on the Hosts.