Understanding GitOps with Argo CD

May 23, 2025

GitOps and Argo CD Lecture Notes

Introduction to GitOps

  • Definition: GitOps is a practice to manage infrastructure and application configuration via Git.
  • Configuration Management: Separates configuration settings from application source code, traditionally stored in version control.
  • Public Clouds & Automation: Allow infrastructure configurations to be stored in Git repositories (e.g., Terraform).
  • Main Concept: Git as the single source of truth for infrastructure management.

Infrastructure Management with GitOps

  • Workflow: Changes made via pull requests, reviewed, merged, and applied automatically.
  • Automation: CI/CD pipelines automatically detect and apply updates post-approval.
  • Tools: Uses Terraform for declarative infrastructure setup.

Role of Argo CD

  • Function: Ensures Git state syncs with Kubernetes state.
  • Deployment Workflow:
    • Create a pull request for application deployment.
    • Argo CD applies changes upon PR approval.
    • Uses kubectl apply or helm upgrade to manage sync.

Continuous Integration and Continuous Delivery (CI/CD)

  • Build Agent (e.g., Jenkins):
    • Pulls source code, runs tests, builds Docker image.
    • Releases images to Docker registry.
    • Updates image tag in GitOps repo.
  • Argo CD:
    • Monitors GitOps repo for changes.
    • Applies updates automatically, enabling continuous delivery.

Setting Up Kubernetes with Minikube

  • Purpose: Local Kubernetes cluster setup.
  • Installation:
    • Use Docker driver for Minikube.
    • Configure kubectl to communicate with the cluster.

Installing Argo CD using Helm and Terraform

  • Helm Charts: Common method to install open-source projects.
  • Terraform Setup:
    • Define provider and resources for Helm charts.
    • Use helm_release resource for deployment.
  • Configuration:
    • Override default variables in values.yaml.

Creating and Managing GitOps Repositories

  • Public GitHub Repo:
    • Contains Kubernetes YAML files and Helm charts.
    • Used to operate the Kubernetes cluster through GitOps.
  • Docker Hub:
    • Stores public Docker images.
    • Authentication needed for private images.

Automating CI/CD with Scripts

  • Script Creation: For build agents to automate deployments.
  • Functions:
    • Tag and push Docker images.
    • Modify GitOps repository with new image tags.

Advanced GitOps Patterns

  • Application Management:
    • Use Argo CD Application CRDs for registration.
    • Enable automatic sync with Kubernetes.
  • App of Apps Pattern: Manage multiple apps and environments.

Using Private Repositories and Docker Images

  • Private Repos: Use SSH keys for authentication.
  • Docker Hub Tokens: Secure image pull for Kubernetes.

Deploying Helm Charts with Argo CD

  • Example: Metrics-server chart for resource metrics.
  • Overrides: Use YAML files to customize deployments.

Kustomize for Deployment Customization

  • Purpose: DRY principle, environment-specific overrides.
  • Structure:
    • Base folder for shared resources.
    • Environment folders for specific customizations.

Conclusion

  • Argo CD and GitOps: Streamline CI/CD pipelines and deployment management.
  • Future Topics: Explore image updater for decoupling CI and CD.