What is GitOps?

GitOps is a philosophy, an operative model for Kubernetes (and other similar technologies too) that provides a set of best practices that unifies cluster and application deployment, management, and supervision. Gitops is a way for developers to manage applications where CI/CD and Git flows are applied (you know Git.. the most popular distributed version control ever). 

But, what is CI/CD? 


CI, Continuous Integration, makes it easier for developers to work simultaneously on different features in the same application. They are automated processes that merge code into a version control repository (like Git, as we said before), build, test, and validate it. Developers can make small constant improvements to their codebase easily and frequently instead of committing a significant new version at once.  It is known that CI and Cloud are the best matches because the Cloud frees us from maintaining on-premise servers. CI automates a big part of our job, as mentioned before, build, test, and deploy code, so it leaves important time to developers for what they are meant to be, developers, and helps us avoid important error injection in that process. Surely, it is hard work to build CI pipelines from scratch, but once you have these pipelines working correctly, it would be an excellent advantage for software development.

CD, Continuous Delivery and/or Continuous Deployment is based on automated pipelines that generate the release of the code that previously successfully passed through CI (if we have CI pipelines working), and finally deploy the new release to a live production environment. It addresses the problem of overloading operations teams with manual processes that slows down the product delivery and avoids human errors when installing new code to production.

Ci and CD practices are connected together, and certainty makes application deployment less risky.

In GitOps, the code that is deployed to production environments are mainly declarative configuration files (YAML files), and they describe how our system should be in our final environment. That means that, as an example, a configuration file should say “the system must have 5 servers” instead of “init 5 servers”. The first sentence is declarative, the second is imperative.

So, in Gitops, CI allows developers to easily integrate adjustments and enhancements through modifications in those configuration files. CD happens when automated software agents do whatever it takes to assure that the production environment reflects exactly what is described on those files.

To sum up, the steps are like this:


  1. A developer makes a pull request to Git to add a new characteristic
  2. The code is reviewed and approved and then merged to the master codebase 
  3. Step 2 activates CI channels, which automatically test, build and deploy the new release into an image registry.
  4. A software agent realizes this update, so it extracts the new release from the registry, and it updates the YAML file in the repository to reflect this change
  5. A software agent on the Kubernetes cluster detects that the configuration has changed, so it updates the production environment with those changes, the new release. 

In step 3, you can use Jenkins as a CI tool. This tool is the most used for pipelines in the world. However, there are other good tools available too like CloudBees, AWS CodePipeline, BitBucket, GitLab, CircleCI, Travis, etc. Jenkins has a variety of plugins to generate pipelines as you wish. There is a big community working to create and enhance Jenkins plugins, so surely you will find a solution for any problem you want to solve. 

As you can see, steps 4 and 5 are the heaviest, and both run in Jenkins and Kubernetes. There, GitOps magic happens exactly when agents synchronize declarative content config files with Kubernetes production environment status.

Kubernetes is an open-source container orchestration platform that automates tasks like deployment, scaling and management for containerized applications. Kubernetes can cluster a bunch of hosts and easily manage them. It can control and manage deployments and updates, as we said before, with configuration files.

To sum up, GitOps is centered around using a version control system, as Git to gather all information, documentation, and code for a Kubernetes deployment, and uses automated agents to deploy changes to the cluster on any environment, generally production environment. That is it! Everything is automated and error-free!!

You may also like


A Summary of GitOps Flow With Minicube (k8s)


Kubernetes in a Cloud Development Environment


Kubernetes Vs. Docker