Software Engineering

GitOps: The Next Evolution of DevOps

GitOps makes a Git repository the single source of truth for what should be running, with an agent in the cluster continuously pulling and reconciling it. We explain the model, how it differs from push-based CI/CD, and what teams gain in reliability, auditability and security.

By EthicalHat Research · · 3 min read
Infographic: The GitOps loop: Git is the source of truth

Most teams already keep application code in Git. Many also keep infrastructure as code there. But the question "what is actually running in production right now?" is often answered by looking at the cluster, a deployment tool's UI or the last successful pipeline run, rather than at Git.

GitOps closes that gap. The term was coined by Weaveworks in 2017, and it has gained momentum with tools like Argo CD and Flux and a GitOps working group formed at the CNCF late last year. The idea is simple: Git holds the desired state of your systems, and automation makes reality match it.

The four core ideas

  1. Declarative. The whole system (applications, configuration and infrastructure) is described declaratively, for example as Kubernetes manifests, Helm values or Kustomize overlays.
  2. Versioned and immutable. That description lives in Git, so every change is a commit with an author, a reviewer and a history.
  3. Pulled automatically. An agent running in the target environment watches the repository and applies approved changes.
  4. Continuously reconciled. The agent keeps comparing live state with Git and corrects any drift.

Push vs pull

In a traditional CI/CD pipeline, the pipeline pushes changes to the cluster:

flowchart LR
  subgraph Push["Push-based CI/CD"]
    C1[Commit] --> P1[CI pipeline] -->|kubectl apply<br/>with cluster admin creds| K1[Cluster]
  end
  subgraph Pull["GitOps (pull-based)"]
    C2[Commit to config repo] --> G[(Git)]
    A[Agent in cluster] -->|watches| G
    A -->|applies & reconciles| K2[Cluster]
  end

With GitOps, the pipeline's job ends when it builds an image and updates the configuration repository (or opens a pull request to do so). The agent inside the cluster pulls and applies the change.

That shift has important consequences:

  • CI does not hold cluster credentials. A compromised CI system cannot directly modify production, which is a significant security improvement.
  • Drift is visible and correctable. If someone runs kubectl edit in production, the agent flags the difference and, if configured, reverts it.
  • Rollback is git revert. The previous state is always one commit away.
  • The audit trail is free. Who changed what, when, and who approved it is recorded in Git.

What it looks like with Argo CD

An Argo CD Application points at a path in a Git repository and a target cluster and namespace:

yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: payments-prod
  namespace: argocd
spec:
  project: payments
  source:
    repoURL: https://github.com/example/platform-config.git
    targetRevision: main
    path: apps/payments/overlays/prod
  destination:
    server: https://kubernetes.default.svc
    namespace: payments
  syncPolicy:
    automated:
      prune: true      # delete resources removed from Git
      selfHeal: true   # revert manual changes in the cluster

A typical repository layout separates base configuration from per-environment overlays:

text
platform-config/
├── apps/
│   └── payments/
│       ├── base/            # deployment, service, config
│       └── overlays/
│           ├── staging/     # 1 replica, staging image tag
│           └── prod/        # 6 replicas, prod image tag, PDB
└── clusters/
    ├── staging.yaml
    └── prod.yaml

Promoting a release to production becomes a pull request that changes the image tag in overlays/prod.

Practical advice

Separate application code and configuration repositories. CI commits to the configuration repo, so application commits do not trigger deployments directly and access can be controlled separately.

Protect the main branch. In GitOps, merging to main is deploying. Require reviews, status checks and signed commits for production paths.

Keep secrets out of Git, or encrypt them. Use Sealed Secrets or SOPS for encrypted secrets in Git, or reference an external secrets manager.

Start with one application. Pick a service with a good test suite, move its deployment to GitOps, and learn how your team handles promotion, rollback and drift before migrating everything.

Decide how to handle emergencies. Sometimes you need to act in the cluster immediately. Define how break-glass changes are made and how they are brought back into Git.

What GitOps does not solve

GitOps is a deployment and operations model. It does not replace testing, progressive delivery (canaries and feature flags) or observability, and it does not stop a bad change from being merged. It makes every change explicit, reviewed and reversible, which is exactly what you want when something does go wrong.

The bottom line

GitOps takes the practices teams already trust for code (pull requests, reviews and history) and applies them to operations. The result is deployments that are more reliable, more auditable and, by removing cluster credentials from CI, more secure.

Our DevSecOps and secure SDLC teams help organisations design GitOps workflows and the platforms that run them.

EthicalHat Research

The EthicalHat research team: penetration testers, SOC analysts and engineers writing about security, software engineering and AI.

Want an expert opinion on your own systems?

Email info@ethicalhat.com or call +1-844-838-4422. Our security engineers are happy to talk it through.