DEV Community

Tomaž Vinko
Tomaž Vinko

Posted on

CI/CD from Zero To Hero 1/N

INTRO

Grab your coffee, beer or whatever keeps you awake, because this series of articles will be a quite long journey. We are going to create a fully functional CI/CD system from the scratch.

Lets start with some official documentation
Continuous integration (CI) is an automation process for developers. Your code changes are regularly built, tested, and merged into a shared repository.

Continuous delivery (CD) is on the other hand a software engineering approach in which teams produce software in short cycles, ensuring that the software can be reliably released at any time and, when releasing the software, without doing so manually.

Those definitions might be hard to understand if you're new to CI/CD. In practice it looks like this:

  • You made some code changes locally
  • Push those changes to your code repository (github...)
  • Code repository receives your changes and executes automated actions that compile and test the code
  • In the final phase, the deployment to your environments (testing, staging, production...) is made. Those deployments can be on cloud (AWS, Azure, Google...) or on premises

In practice, those cycles might be more complicated. But the point is that the whole procedure is fully automated - from code commit to deploying.

Our CI/CD pipeline

Through the next tutorials, we are going to implement following pipeline:

  • GitHub Action will be triggered on new code commit
  • Action will prepare the environment for pulling your repository
  • It will compile your system and run tests inside this environment
  • Deploy system to Kubernetes cluster on your local machine

Image description

CI/CD stack

As you might guess, there are many tools that help you reach those goals. Our stack will use following technologies:

Kubernetes

Open-source container orchestration system that enables you to automate containerized application deployment, scaling, and management. You can install it from here

Minikube

Kubernetes cluster contains master and worker nodes running on different machines. Deploying those kind of system would be overkill for your daily development work.
Minikube enables you to run a single-node Kubernetes cluster right on your development PC.

GitHub

We will trigger code compilation and testing with the GitHub Actions. You will need a GitHub account

ngrok

GitHub Actions will deploy system on Kubernetes cluster running on your development machine. You probably don't have your PC accessible from outside.
ngrok is a free tunneling system to expose your local services externally.
You can create a free account from official ngrok site

Helm

Package manager for Kubernetes.

WHAT ARE WE CI/CD-ing?

Note that focus won't be application per se as we're deep diving into CI/CD, but let's describe it anyway.
You could use CI/CD template described in this tutorial for any kind of application, regardless of programming language (with a minor adoption)

Our project will be Tracking Service Platform made of three parts:

API Microservice

API receives events which contain two-piece information: user account and any arbitrary data.
When the event arrives at our almighty API, it checks the account status that can be active, disabled or non-existing.
If account is active (found in database with active status) then some interesting things happen - it broadcasts it to subscribers.

Mosquitto

Broadcasting events to subscribers lead us to need for some kind of publisher/subscriber system.
The middleman between API and clients is Mosquitto - message broker which implements MQTT protocol.

Clients

Those can be different types of clients that receive published events. In our case, it's a console application.

Image description
The code is hosted on GitHub where each CI/CD step will be explained in the next tutorials.

Top comments (0)