Implementing Scalable GitOps With Argo CD and ApplicationSets: A Case Study

This infrastructure was developed at Nexxen, where I’m currently employed.

Transitioning from the inefficient “App of Apps” model, we adopted GitOps with Argo CD and ApplicationSets for improved efficiency and reliability. The old system, with its hunderds of declarative Argo Applications and frequent manual changes them, was operationally taxing, error-prone and not scalable.

The shift to a declarative GitOps approach using ApplicationSets has significantly minimized manual interventions, enhancing the scalability and accuracy of our deployment processes.

In this blog post, I’ll explore our approach to establishing a scalable and maintainable GitOps infrastructure using the Argo CD ApplicationSets CRD.

I will delve into how we:

  1. Bootstrap and manage Argo CD configurations.
  2. Structure our ApplicationSets and GitOps deployments repository for scalability (utilizing the git generator).
  3. Leverage ApplicationSets to automate deployment processes.
  4. Manage and scale our deployments across multiple clusters and environments.

I provided real examples, from two teams, Octo and Datamine2, to give you a better understanding of how we structure our deployments.

Introduction to Our GitOps Setup

We divided our configurations into two repositories.

This strategy safeguards our management configurations and aligns with the principle of least privilege.

Our GitOps framework is built around two main repositories:

argocd-management repository:

Manages Argo CD’s foundational configurations, including AppProjects and ApplicationSets.

gitops-deployments repository:

Acts as the single source of truth for all declarative deployments within our organization.

This is a monorepo gitops repository that contains all the Kubernetes manifests that are used/deployed across all the company.

Our Approach to Bootstrapping and Managing Argo CD Configurations

Although ApplicationSets offer significant reductions in time and manual errors by automating deployment processes, integrating them with Kustomize has elevated their effectiveness.

By managing ApplicationSets and AppProjects through Argo CD applications themselves (app-of-appsets and app-of-appprojects) we have automated even the application of these configurations to the cluster. This meta-management layer ensures that all changes are self-maintaining and self-applying, which enhances automation and reduces the need for manual oversight even further.

We utlize the power of the Application CRD to manage the AppProjects, and the Application factories, the ApplicationSets!

Below, I’ll explain our approach more in detail:

Diagram: How It’s Working Together

Diagram illustrating the whole operation

Understanding Our ApplicationSet Approach

Our ApplicationSets Strategies

We have two main strategies for our ApplicationSets:

GitLab Subgroup-based ApplicationSets

ApplicationSets are primarily organized per GitLab subgroup, automatically generating Argo CD Applications for each service or application within the subgroup.

Prod and Non-Prod Environments

Examples ApplicationSet Manifests

Real example ApplicationSets config that we use for our own DevOps team (“Octo”):

These ApplicationSets targets the orphans/infra directory within the octo subgroup in the gitops-deployments repo, focusing on the prod environment.

For more details about the appset_config*.json files, refer to the Q&A section.

Scale Strategies with ApplicationSets

Our architecture leverages ApplicationSets to facilitate scalability in the following ways:

Example of Environments (envs) Structure

The envs directory structure plays a crucial role in how ApplicationSets manage deployments:

envs/
├── non-prod-sandbox/
│   ├── appset_config-a.json
│   ├── appset_config-b.json
│   ├── kustomization.yml
├── non-prod-staging/
│   ├── appset_config-c.json
│   ├── kustomization.yml
├── prod/
    ├── appset_config-d.json
    ├── kustomization.yml

Q&A