CI/CD from Zero To Hero 1/N
Published: 2021-12-21 20:46:33

###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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5m7vhy25aiwvjzkweelj.png)
###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](https://kubernetes.io/docs/tasks/tools/)

####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](https://ngrok.com/) site

####Helm
[Package manager](https://helm.sh/docs/intro/install/) 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wyu0rjtb6qygj2c4o3bn.png)
The code is hosted on [GitHub](https://github.com/tvinko/TrackingServicePlatform) where each CI/CD step will be explained in the next tutorials.