GitOps Basics and Workflows

CNPA Domain: Platform Engineering Core Fundamentals (36%) Β· Continuous Delivery & Platform Engineering (16%) Topics: Continuous Delivery and GitOps, GitOps Basics and Workflows

Overview

GitOps is an operational model where the entire desired state of a system β€” applications, infrastructure, configuration β€” is declared in a Git repository and continuously reconciled by automated agents. Git becomes the single source of truth, making all changes auditable, reversible, and reliable.

For platform engineers, GitOps is not just a deployment strategy β€” it's the foundation for managing multiple environments, tenant clusters, and platform capabilities at scale.


The Four GitOps Principles (OpenGitOps)

The OpenGitOpsarrow-up-right project defines four core principles:

#
Principle
Meaning

1

Declarative

Desired system state is expressed declaratively

2

Versioned and Immutable

State is stored in Git with full history

3

Pulled Automatically

Agents automatically pull and apply changes

4

Continuously Reconciled

Agents continuously compare desired vs actual state


Push vs Pull Deployment Models

Traditional Push Model (CI-based)

CI Pipeline
    β†’ kubectl apply (push)
    β†’ Cluster

Problems:

  • CI system needs cluster credentials (security risk)

  • No continuous reconciliation β€” drift goes undetected

  • Hard to audit who changed what, when

GitOps Pull Model

Benefits:

  • Cluster credentials never leave the cluster

  • Drift is automatically detected and corrected

  • Full audit trail in Git history

  • Rollback = git revert


GitOps Workflow


Argo CD

Argo CDarrow-up-right is the most widely adopted GitOps continuous delivery tool for Kubernetes.

Core Concepts

Concept
Description

Application

An ArgoCD CRD linking a Git source to a cluster destination

Project

Grouping of Applications with RBAC policies

Sync

The action of applying Git state to the cluster

Health

Whether Kubernetes resources are functioning correctly

Example ArgoCD Application

ArgoCD Sync + Health Status


Flux CD

Fluxarrow-up-right is a CNCF graduated GitOps toolkit with a modular, Kubernetes-native controller architecture.

Flux Components

Controller
Purpose

source-controller

Monitors Git repos, Helm repos, OCI

kustomize-controller

Applies Kustomize resources from sources

helm-controller

Manages HelmRelease objects

notification-controller

Sends alerts and receives webhooks

image-reflector-controller

Monitors container registries

image-automation-controller

Auto-updates image tags in Git


Repository Structure Patterns

Monorepo (App + Config in one repo)

Best for: small teams, simple services.

Split Repos (App repo + GitOps repo)

Best for: platform teams managing many services, multi-team environments.

Platform teams typically maintain a central GitOps repository and give teams self-service access to submit changes via PRs.


Reconciliation and Drift Detection

GitOps agents continuously run a reconciliation loop:

This means manual kubectl changes are automatically reverted if selfHeal is enabled β€” ensuring Git is always the source of truth.


GitOps vs Traditional CI/CD

Aspect
Traditional CI/CD
GitOps

Deployment trigger

CI pipeline push

Git commit + pull by agent

Credentials

CI server holds cluster creds

Agent inside cluster only

Rollback

Re-run pipeline

git revert

Drift detection

Manual/none

Automatic, continuous

Audit trail

CI logs

Git history

Multi-cluster

Complex

Natural (per-cluster agents)


Key Takeaways

  • GitOps makes Git the single source of truth for desired system state

  • The pull model is more secure than push: cluster credentials never leave the cluster

  • ArgoCD and Flux are the dominant CNCF-ecosystem GitOps controllers

  • Reconciliation loops continuously detect and correct drift

  • Use a split repo pattern (app repo + GitOps repo) for multi-team, multi-environment platforms

  • GitOps makes rollback trivial: revert the commit


Further Reading

Last updated