Building a continuous deployment pipeline

By creating a CI pipeline, we made a first step towards being an effective engineering organization. Thanks to the workflow of working in individual branches and merging them back to the master branch after going through automated testing and human reviews, we can assume that the code present in the master branch is of high quality and safe to deploy. Knowing that, we will focus on the next challenge of releasing code automatically as new code gets merged into the master branch.

By continuously releasing new code, you drastically accelerate the feedback loop process that DevOps provides. Releasing new code to production at high velocity lets you collect real customer metrics, which often leads to exposing new and often unexpected issues. For many companies, deploying new code to production is a challenge. It is easy to get anxious about that exercise if releasing code means thousands of new commits all going out to production at the same time in a process that is occurring only a few times a year. Those companies are often the ones who schedule their maintenance operations late at night and often during weekends. Adopting a more modern approach, such as the one we will go through in the remainder of the chapters, will have a tremendous positive impact on the work-life balance of the engineering team.

Most of the highly admired tech companies such as Google don't deploy code on Fridays. The goal is to avoid pushing bugs out just before the weekend, which otherwise could lead to unexpected pages on Saturdays or Sundays. In addition, because they don't fear to deploy code, a lot of those changes will go out to production at pick hours so that they can quickly catch any issues related to load.

In order to implement our continuous deployment pipeline, we are going to look at two new AWS services called CodeDeploy and CodePipeline.

CodePipeline will let us create our deployment pipeline. We will tell it to take our code from GitHub, similarly to how we did before, and send it to Jenkins to run our CI testing on it, but instead of simply returning the result to GitHub, we will then take the code and deploy it to our EC2 instance with the help of AWS CodeDeploy.

CodeDeploy is a service that will let us properly deploy code to EC2 instances. By adding a certain number of configuration files and scripts, we will be able to rely on CodeDeploy to deploy and test our code reliably. Thanks to CodeDeploy, we won't have to worry about any kind of complicated logic when it comes to sequencing our deployment. CodeDeploy is tightly integrated with EC2 and knows how to perform rolling updates across multiple instances and, if needed, perform a rollback.

In Chapter 3, Treating Your Infrastructure As Code, we looked at how to configure servers and deploy the Hello World application using Ansible. While this solution allowed us to illustrate how to use configuration management, this solution is as good as what we could hope for of a more critical service. There isn't any notion of sequencing, no good feedback mechanism on how the deployment went, and we didn't implement any validation steps. Having a dedicated service geared towards deploying in AWS will make deploying applications a lot better as we will see.

In order best to demonstrate these services, we will first build new, generic Node.js web servers using Ansible.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset