How to use GitOps with ArgoCD
By: Ahmet Avcı
Tags: Argo Cd, Kubernetes, DevOps, Git, Gitops

In this blog post, we are going to explain what GitOps and ArgoCD are and how they can be useful for DevOps process by showing you how we use them at Trendyol Seller Ads team.

We are not going to go through the setup process of our CI/CD pipeline and ArgoCD in this blogpost. Main focus will be on how we configure and use GitOps and ArgoCD as developers.

Let’s start by explaining the fancy terms;

What is GitOps and ArgoCD?

GitOps is a way of implementing Continuous Deployment for cloud applications. It allows developers to deploy faster and more often by using tools that developers are already familiar with such as Git and other CD tools.

The core idea of GitOps is having declarative descriptions of desired state of production in a Git repository like source code and an automated process to match these desired and current states of production. It allows developers to only push commits to the repository whenever they make deployment to the production environment while automated system handles everything else.

And this is where ArgoCD comes into play. It completes the most crucial step of GitOps by ensuring that the repository and production environment states are always in sync. It reports & visualizes any deviation as well as provides mechanisms to automatically or manually sync the live state to the desired target state.

Some of the best features of ArgoCD are;

Declarative and version controlled application deployments

Automated deployment of applications to specified target environments

Support for Kustomize and Helm application declarations

CLI and a sweet web UI for Kubernetes resources

PreSync, Sync, PostSync hooks to support complex application rollouts such as blue/green and canary upgrades

Why Have We Decided to Use ArgoCD?

The biggest drawback in our CI/CD pipeline was that configuration management of applications across environments and clusters. Whenever there was a change or new feature for our applications, we had to apply these changes manually or maintain jobs with specific kubeconfigs for each cluster to automatically make deployments.

We wanted to automize all of these processes and become closer to Continuous Deployment. And that’s how we discovered ArgoCD.

Thanks to ArgoCD;

We are able to make deployments to different environments and clusters from a single source of truth.

Deployment, ConfigMap or Istio config changes are reflected to all production clusters dynamically and instantly.

It provides us the two sided syncing feature. ArgoCD recognizes the changes on our configurations and start syncing Kubernetes and also, it notices any deviation on the Kubernetes side and sync it back to the desired state. Without ArgoCD, Kubernetes resources would be unsync until the next deployment.

If we want to relocate an application from a cluster to another cluster (maintenance work might happen by DevOps team), just one line change in the target clusters works.

We are able to follow sync situation of our desired and current status of applications and be aware instantly of any undesired event on Kubernetes resources with ArgoCD UI and it’s notifications.

When we want to increase the number of replicas, we had to wait for Gitlab jobs in the pipeline to schedule and run. Now it’s just a change in the Git repository and we are able to scale up instantly.

How Do We Use GitOps with ArgoCD?

We have project repositories for each application in our team. Their responsibilities are;

hold the source code and make static analysis on it

compile and run unit & integration tests

package the application and run automation tests

create a deployable version of the application

And we have one global Manifest repository to manage infrastructure configurations of these applications. We manage where to deploy our apps and with what settings in this repository.

We keep declarative Kubernetes and ArgoCD configurations in here. And the job of ArgoCD is to make sure this Manifest repository and Kubernetes clusters are in sync.

Let’s look at how we use GitOps and ArgoCD on the Figure 1;