ci/cd

Continuous Integration and Coninuous Delivery (CI/CD) #

This article describes a workflow for implementing a CI/CD pipline to deploy a microservice architecture on a kubernetes cluster. The workflow was implemented using Azure DevOps but can be applied to any CI/CD pipeline (AWS Codepipeline, Jenkins, Travis CI or Circle CI).

Customer scenario #

John, the CTO of a fast-growing startup, decided it’s time to streamline their development processes. He wanted to incorporate best practices from DevOps to facilitate rapid development and, most importantly, ensure swift releases into production without any major hitches. He chose to implement Continuous Integration/Continuous Delivery (CI/CD) using Microsoft Azure.

To implement this, John’s first step was to ensure that all developers merged their changes to the main branch daily. This way, they would minimize the cost, time, energy, and hassle of dealing with merge conflicts.

The next step involved Automated Build. The modular architecture helped John’s team to isolate and test individual blocks of codes whenever they were added to the main branch. They utilized Azure Pipelines, a cloud service, to automatically build and test code projects and make them available to others, reducing the overall development time.

They further introduced Automated Testing as a mandatory step to this build. This ensured that all code changes were validated, and bugs were identified early and promptly fixed. The Azure Test Plan was used as a tool to provide all types of testing from manual to exploratory and load testing.

John knew that Continuous Integration alone was not enough. Hence, the team implemented Continuous Deployment. Every change that passed through all stages of the production pipeline was released to the customers, making it faster and easier for them to get enhancements.

To achieve continuous deployment, the team leveraged Azure DevOps and Azure Pipelines to streamline the process of provisioning, testing, and deployment to different environments. This ensured that any successful change made to the codebase would be automatically reflected across all operating environments in real-time.

John also introduced Infrastructure as Code (IAC), which allowed them to manage their infrastructure more efficiently in the cloud. With Azure Resource Manager Templates, the team was able to automate the creation, deployment, and management of Azure resources.

Implementing CI/CD helped John’s team to rapidly iterate on their software, improve its quality, reduce bugs, and in return, drastically improved their release rate. The team was satisfied, as errors were minimal, roll-backs were quicker, and productivity increased.

Implementing CI/CD in Azure eliminated the need for manual intervention, granting John’s team more time to focus on creating a feature-rich and robust platform for their customers. John was delighted with the efficiency and productivity his team achieved through the CI/CD implementation in Azure, reaching their goal of faster and safer deliveries.

CI/CD Reference Architecture #

Reference-Architecture

Technical realization #

When the continuous integration (CI) pipeline starts, it does numerous checks, tests, and builds.

  • Initially it generates a docker image (artifact) into a registry.
  • If each test and check in the CI pipeline passes successfully, the final step is to deploy to Kubernetes. This is where the continuous deployment (CD) pipeline comes into play. The CD pipeline listens for changes in the ACR, pulls the image and deploys it into the Kubernetes cluster.
  • The workflow continues to go through the cycle, allowing the application to be improved and updated. This is why companies use CI/CD pipelines - it automates the code delivery process. The process enables developers to automatically build, test, and deploy their applications to various environments, such as staging, pre-production, and production environments.
  • CI/CD practice allows developers to integrate changes more frequently and reliably, while also making error detection more immediate and enabling quick fixes. This, in turn, leads to improved customer satisfaction and enhanced productivity.
  • Some environments support continuous deployment which is like continuous delivery with automatic deployment to production when all tests have been passed successfully (without manual approval).

So, the general workflow steps are:

  1. Code changes are committed and pushed to a version control repository.
  2. The CI/CD pipeline is triggered, usually through a webhook.
  3. The application is built and initial tests are run.
  4. If the tests pass, the application is deployed to a staging environment.
  5. Further testing is executed in the staging environment.
  6. Any bugs identified are reported back to the development team.
  7. Once the changes are approved, the application is deployed to the production environment.
  8. The application is monitored and any detected problems are fixed, restarting the cycle.

Transcript of my journey #

Transcript Application Workflow

Addendum #

Todo: #

  • Clean code:
    • Main codebase location: elft-net/DevOpsAutomation which is private
    • Has been a bumpy ride, codebase should be cleaned, refactored
    • Consider sharing codebase => now only https://github.com/elft-net/AzurefromScratch is public.