Introduction to GitOps Practices with ArgoCD

Introduction to GitOps Practices with ArgoCD
Photo by Annie Spratt / Unsplash

It's 2024 and being a developer is as hard as ever.

You're not only expected to learn how to build stuff, you also have to learn how to deploy and maintain them.

You don't have to know all the gritty details because that's for your "ops" people to handle but it would be beneficial for you to learn the higher-level practices and concepts.

One of these practices is called GitOps.

Don't worry, it's not some sci-fi stuff. It's actually very simple.

I can teach it to you in one sentence:

Use Git as your source of truth

It's as simple as that but you might have questions like, what, why, and how.

This is what I'll be discussing today.

The first question we have to ask is why. Why was this created?

To answer that, let's take a quick history lesson.

The Rise of Everything as Code

Everything started with the concept of Infrastructure as Code with Terraform as the defacto tool in this space.

Eventually, we did not only do infrastructure but also networking, policies, configurations, and security as code.

💡
If you're interested in Terraform then feel free to check out this article.

Now you might ask, "Where does GitOps come into play?"

GitOps enhances "X" as Code Movement

GitOps methodology states that infrastructure and application configurations should be stored in Git and be used as the single source of truth.

With this, your Git repository will hold the entire state of your application.

You can also use automation tools such as ArgoCD to ensure that the actual state of your infrastructure or applications matches the desired state stored in the repository.

This is GitOps in a nutshell:

Using Git as your infrastructure/applications source of truth

As I said before there are tools that help us with this such as ArgoCD.

Let's learn more about it.

Synching between our actual and desired state

If you have an application that is hosted on a Kubernetes cluster and want to implement GitOps then ArgoCD is your best bet.

So let's say you have your k8s manifests stored in Git and you want to make sure that it is automatically synced with your cluster.

No need to do kubectl apply, you just want it to be automatically synced and maintain the sync, so if anyone did any manual changes it will sync back to your desired state (the one in the Git repository).

This is essentially what ArgoCD helps us do.

But what other infrastructure components?

Okay, it's a bit tricky here but you can either:

  • Implement it directly in your CI/CD pipelines and have a cron job that checks if the infrastructure matches the desired state.
  • If you're using Terraform, you can use Atlantis but I don't think this handles the synchronization problem.
  • You can ditch Terraform and use Crossplane as it's fully compatible with both Kubernetes and ArgoCD.
💡
If you're interested in Crossplane then feel free to check out this article.

Learn More

This is just a more introductory article to what is GitOps and a bit about ArgoCD.

If you want to learn more then I'd suggest reading the following articles:

Thanks for reading.

Member discussion