ArgoCD - GitOps

De Marijan Stajic | Wiki
Aller à la navigation Aller à la recherche

GitOps

The term GitOps refers to the practice of deploying a pipeline that connects your repository (GitLab) to your Kubernetes cluster in order to do Infrastructure as Code (or Policy as Code, Network as Code, etc.). Whenever a change is made in the repository, it is then sent to a pipeline like ArgoCD, which applies the change to the Kubernetes cluster. In the CI/CD concept, GitOps is concerned only with CD (Continuous Delivery), but it remains distinct from traditional CI/CD and should not be confused with it.

Why not CI/CD or CLI

Engineer decides not to use CI/CD for deploying their code on the Kubernetes cluster because it requires exposing credentials. Even though solutions exist to secure credentials, it is still generally not recommended. As for using the CLI, the issue is that modifications are made directly in the infrastructure. If these changes are not pushed to Git, they risk being overwritten by the code from the repository. So it's why we decide to use GitOps methodology.

Principles

A GitOps tool is designed to apply configurations to a Kubernetes cluster, requiring configuration files to be in .YAML or .JSON format. These files must be stored in a Git repository. Once a configuration file is committed to Git, the GitOps tool allows users to choose the target cluster for deployment (e.g., development, staging, or production).

It operates using a Reconciliation Loop, which consists of three main steps:

  • Observe : The tool monitors the Git repository for any new configuration files that have been pushed.
  • Diff : It compares the newly pushed configuration with the current state of the Kubernetes cluster to identify any differences.
  • Act : After approval from the team (recommended), the tool applies the changes to the Kubernetes cluster.

ArgoCD