Introduction to GitOps with ArgoCD

Louis Moon
4 min readJan 2, 2021

-

Overview

Explains the concept of GitOps and show example of GitOps pipeline with ArgoCD.

What is GitOps?

GitOps is an extension of IaC(Infrastructure as a Code) and a pattern to do Continuous Deployment for cloud native applications.

It works with 1) Git repository as a source for declarative infrastructure configuration files and 2) Continuous Deployment tools for sync the configuration files with applications being served. The sync process is optional. (auto or manual)

It is mainly used to manage resource of Kubernetes. So, I will show example for Kubernetes manifest files below.

IaC: Infrastructure as a Code. IaC is a way for managing manifest files for infrastructure by a code.

Cloud naive: In general, cloud native is a way for building and running applications by using cloud computing.

Advantages of GitOps

  1. Makes it easy to check the configuration of the deployed and running application by checking manifest files on git repository.
  2. The histories of deployment applications is controlled by version control system like Git. When there are some problems with the deployed applications, it is easy to rollback application.
  3. Human intervention and human error can be minimized by delegating the responsibility of deployment applications to continuous deployment tools.

GitOps Pipeline (with argoCD)

overall development flow

argoCD

There is many CD(Continuous Deployment) tools for GitOps. JenkinsX, Tekton, Spinnaker, ArgoCD, etc. I chose argoCD for CD tool because it is lightweight and only focus on CD for kubernetes unlike others.

features

  • SSO integrations
  • support for various kubernetes config file manage tools (ex. Kustomize, ksonnet, helm, etc.)
  • manage applications on multiple clusters
  • rollback to past release point
  • pre-sync, post-sync action and it make blue-green, canary deployment possible.
  • notification for sync status
  • various sync options(Auto or Manual / All sync or Partial sync)
  • (more feature is in here)

Example for CI (with Github Action)

  • My kubernetes manifest files are managed by Kustomize.
  • If you do not use Kustomize, yon can set changed docker image by sed(stream editor) command.

Example for CD — manifest repo

Kubernetes configuration files in my manifest repo are managed by Kustomize. The files in base directory are template configurations and the files in development directory are application configurations. (sample link)

manifest files

/sample-infra/app/development/kustomization.yaml is,

Example for CD — ArgoCD

ArgoCD install guide is Here.

create app on argoCD
  • There is two sync policy. If you choose auto policy, argoCD check code change in manifest repo automatically.(recommend to Develop config). If you choose manual policy, you have to deploy application manually. (recommend to Production config)
  • If you want to deploy app on external cluster, It is necessary to register credential to argoCD.(link)
  • ArgoCD automatically recognize which tool is applied. (Kustomize, Ksonnet, helm, etc.)

After create app, argoCD deploy application like this.

after sync application

If you change docker image or resource of kubernetes objects on manifest repo, argoCD sync deployed application with manifest repo AGAIN.

sync process

ArgoCD provide deployment histories and you can rollback on web UI if you choose manual sync policy.

deployment histories

ArgoCD provides live manifest, events, log from kubernetes objects on Web UI.

live manifest
events on kubernetes object
logs from kubernetes object

Conclusion

  • GitOps make deployment process of application faster and more stable.
  • You can check the histories of deployment from git commit log by using GitOps pattern.
  • argoCD is lightweight and has powerful features for continuous deployment on kubernetes. So I recommend argoCD.

--

--

Louis Moon

Backend Software Engineer. Live in S.Korea. Interested in Backend / DevOps / ML. moonkwoo777@gmail.com