Skip to Content
Mengty Learns
GitOps

What Is GitOps? (Pull vs Push)

How GitOps uses a declarative Git repository as the single source of truth and an in-cluster pull agent to converge cluster state.

explanationbeginnerTested with argocd 3.6 (docs), flux 2.10 (docs)Updated Nov 26, 2026

TL;DR

GitOps makes a declarative Git repository the single source of truth for infrastructure and apps. Instead of CI pushing kubectl apply with cluster-admin keys, an in-cluster pull agent (Argo CD or Flux) watches Git and continuously converges the cluster to match.

Intent

TL;DR

Understand the four OpenGitOps principles and why pull-based reconciliation beats ad-hoc kubectl apply scripts from CI runners.

Problem

In traditional push-based CD, your CI pipeline builds an image, logs into the cluster with a kubeconfig secret, and runs kubectl apply or helm upgrade. That creates two risks: CI holds powerful cluster credentials, and once the CI job finishes, nobody notices if someone manually edits the cluster later.

Push CI requires external cluster credentials; Pull GitOps keeps cluster credentials inside the cluster.

Solution

The OpenGitOps standard defines four principles:

  1. Declarative: The desired state of the system is expressed declaratively (Kubernetes YAML, Helm values, Kustomize).
  2. Versioned and Immutable: Desired state is stored in Git with full commit history, PR reviews, and git revert rollbacks.
  3. Pulled Automatically: Software agents inside the cluster (Argo CD or Flux) automatically pull desired state declarations from Git.
  4. Continuously Reconciled: Agents observe actual cluster state and continuously apply changes whenever actual state diverges from Git.

Real-world analogy

▶ Flow: watch it work

GitOps Pull Loop: Commit → Detect → Sync → Cluster == Git

Overview of GitOps Pull Loop: Commit → Detect → Sync → Cluster == Git. 7 steps.
Overview7 steps in this flow

Press Start or tap any step dot to trace the path.

▸All steps (7)

Code

An Argo CD Application manifest declaring which Git repo and path to reconcile into the cluster:

# Declarative Argo CD Application (not run — requires Argo CD installed in cluster)
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: web-app
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/example/k8s-config.git
    targetRevision: main
    path: apps/web
  destination:
    server: https://kubernetes.default.svc
    namespace: production
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

When to use / when to avoid

When to use
  • You run Kubernetes clusters and want auditable, PR-reviewed deployments with easy git revert rollbacks.
  • You want to remove cluster-admin kubeconfig secrets from external CI runners.
When to avoid
  • You are deploying a single static site to a managed host (a simple CI deploy step is lighter than running Argo CD or Flux).
  • Your team still relies on imperative hotfixes via kubectl edit without committing back to Git.

How to implement

Separate app code and config (or use a dedicated config path)

Keep declarative Kubernetes manifests in a tracked Git branch.

Install Argo CD or Flux in the cluster

Grant the in-cluster controller read-only access (deploy key or GitHub App) to your config repo.

Point an Application or Kustomization at the repo

Enable automated sync and selfHeal once your manifests are tested in CI.

Pros / Cons

Pros
  • Least privilege: CI never needs direct write credentials to production Kubernetes.
  • Audit trail and instant rollback via Git history and PR reviews.
Cons
  • Adds an in-cluster controller to operate, monitor, and upgrade.
  • Secrets cannot be committed in plaintext—requires Sealed Secrets, SOPS, or External Secrets Operator.

Relations

Check yourself

Check Yourself

1. How does pull-based GitOps reduce the blast radius of a compromised CI runner?

2. In GitOps, how should you roll back a broken Kubernetes config change?

Sources