What is GitOps?

The term was first coined by Weaveworks in a popular article from August 2017. The problem it intends to solve was how to efficiently and safely deploy a Kubernetes application. The main tenants of this philosophy are:

  • Use a Git repository as a single source of truth.
  • Any change is made in the form of a Git commit.
  • When the application state differs from the desired state (that is: what’s in Git), a reconciliation loop detect the drift and try to reach this state.

Image for post

directly from Weaveworks

The reason why GitOps is especially suited to deploy cloud-native applications is that Kubernetes follows the same declarative way of doing things:

  • You submit a bunch of Kubernetes objects through a declarative document as YAML or JSON.
  • Kubernetes Operators process is endlessly evaluating the difference between the submitted objects and their real state in the cluster, adding, modifying, or deleting them as needed.

When you understand the concept, you can apply the GitOps way not only to Kubernetes application but to anythings described with code, for example, code infrastructure.

But what is the difference between GitOps and the final deploy step of my CICD pipeline?

Very often your pipeline is triggered by a change in code (if not, it really should!), so it’s in fact the same starting point as GitOps. Your final pipeline step then run a command like kubectl apply. You so run an imperative command to reach the desired state.

In GitOps, you won’t do this: it’s an external tool that detects the drift in your Git repository and will run these commands for you. You can think of it as a “pulling” way of doing things.

Let’s look into these tools.

What tools are available to implement GitOps?

The most commonly used tools are Flux from Weaveworks and ArgoCD. You may find extensive comparisons of both tools but to sum it up:

  • Flux can only observe one repository at a time, meaning you have generally one flux instance running for each application.
  • ArgoCD may observe multiple repositories, comes with a GUI dashboard, maybe federated with an identity provider: it’s more enterprise-ready.

In this article, we will look to implement a GitOps model using ArgoCD.

#gitops #code #argo-cd #kubernetes #cloud #github

How to build a GitOps workflow with ArgoCD, Kustomize & GitHub Actions?
10.20 GEEK