Understand The Key Concepts of Continuous Integration & Continuous Deployment
Tags: devops, docker, kubernetes
Published: 2020-01-02 09:27:35

Today’s enterprises are under increasing pressure to deliver software faster than their competitors, differentiated solely by the application quality and the developers who build them.

As a result, more and more organizations are turning to <b>continuous delivery (CD)</b> to improve their ability to plan, build, test and release applications to market quickly and at scale.

Your company is interested in learning how to leverage continuous delivery for faster software deployment but doesn’t know what all the terms and concepts mean.

Luckily, this article can help you: read on for a guide on the basic terms and concepts around continuous delivery and why CD is essential.

What’s the <b>difference between CI and CD</b>?

You must have heard & probably just assumed that <a href="https://dzone.com/articles/learn-how-to-setup-a-cicd-pipeline-from-scratch">CI/CD</a> means writing scripts to build pipelines to deploy applications. Well, you’re sort of right. First, let’s contrast & <b>compare CI and CD</b>.

CI is about taking code-to-artifact.

So, basically, a developer:
1. Writes code
2. Checks in code
3. Code goes through a build process
4. An artifact is created
5. The artifact is stored within a repository

That’s it. Following is a visual representation of the explanation above:
![Visual Representation of Continuous Integration](https://thepracticaldev.s3.amazonaws.com/i/cz4xio00398wcub0nyka.png)

Continuous Integration has a mature set of tools, technologies, and established best-practices. There are a plethora of vendors and you’re most likely using one of them.

So what happens after the artifact is ready? This is where CD comes in.

<h2>What is an Artifact/Service?</h2>

<b>Service</b> – A service is a self-contained software that serves as part of a collection of services that make up an application. Common examples are <a href="https://www.goodworklabs.com/kubernetes-vs-docker-swarm-how-to-choose-a-complete-breakdown/">Docker containers, Kubernetes pods</a>, or a single Node.js app.

<b>Artifact</b> – Each service has its own deployment requirements. For example, the Node.js application will require you to package your service in a different way to prepare it for deployment. This packaged and ready state is an artifact. So, an artifact is a service that is built, packaged, and ready for deployment.

<h2>The Six Stages of Continuous Delivery</h2>

<h3>CD essentially includes the following stages:</h3>
![Stages of Continuous Delivery](https://thepracticaldev.s3.amazonaws.com/i/hdmbhidcr62qej3ilc8w.png)

Once an artifact is ready for deployment, you need to take it through these six phases that need to be supported by your CD <a href="https://www.plutora.com/blog/understanding-ci-cd-pipeline">pipeline</a>.

<h2>What is a Pipeline, Stage, Workflow</h2>
To understand the basics of CD, There are a few important terms you have to become familiar with: pipeline, stage, and workflow. When you kick off a deployment, your artifact goes through various stages in order to be deployed.

<h3>Stages</h3>
![Continuous Deployment Stages](https://thepracticaldev.s3.amazonaws.com/i/j9j6mtlxfyebsg3qsugg.png)

<h3>Workflows</h3>
Each stage requires some actions with that artifact. These things that you’re doing are referred to as a workflow.

Workflows typically automate three things: Service deployment, test and verify the service and then rollback (if necessary).

Say, for example, stage 1 is:
1. Provisioning a QA environment in AWS
2. Deploying my artifact to a QA environment
3. Running a bunch of tests
4. Tearing down the environment
5. Verify the health of the application
6. Rollback, if necessary

This is your stage 1 workflow. Once stage 1 is complete, you then go to stage 2, stage 3, and so on.

<h2>Here is a visual:</h2>
![Continuous Deployment Workflow](https://thepracticaldev.s3.amazonaws.com/i/9ukoor166drolhyr7pnu.png)

<h3>Canary and Blue/Green Strategies</h3>
A common attribute of workflows is a release strategy. Specifically, the most popular release methodologies are Blue/Green & Canary deployments. As you progress within your later stages and approach production, you need a release strategy that ensures the safety and reliability of the deployment.

So, your product deployment in your pipeline will want to incorporate a release strategy within its workflow.

<h3>Environments</h3>
An environment is where you deploy your application; they represent the infrastructure on which services run.

This can be, for example:
1. AWS
2. Azure
3. Google Cloud
4. Your own data center

Your workflows deploy your applications to the necessary environment.

<h3>Pipeline</h3>
A pipeline is a term used to describe all the stages (and their corresponding workflows) stitched together. Remember, each stage has a workflow. Thus, a pipeline assembles the stages and their corresponding workflows. A pipeline is an umbrella term for all of the pieces working together.

<h3>Here is what a CD pipeline looks like:</h3>
![Continuous Deployment Pipeline](https://thepracticaldev.s3.amazonaws.com/i/1h0pv8mnprehlwus9fz9.png)

<h3>Triggers</h3>
A trigger is an event that occurs to kick off your pipeline. An event can be any of the following:

1. Merging your Git branch into master
2. A new artifact is available in the artifact repository
3. A new .tar artifact file has been uploaded to a folder for deployment
4. A recurring time
5. A webhook

<h2>Summary</h2>
That’s it! Now you understand that a pipeline consists of stages. Each stage corresponds to an environment.

Each stage has a workflow that does what is required to test/deploy your application.