# GitOps Principles

> A deployment model where the desired state lives in Git and an in-cluster agent continuously pulls and reconciles it. Free notes, key concepts, resources and a...

Canonical: https://www.internhack.in/roadmaps/tracks/devops/gitops-principles
Last updated: 2026-11-28

A deployment model where the desired state lives in Git and an in-cluster agent continuously pulls and reconciles it.

Intermediate · about 3 hours · difficulty 2/5

Learn first: [Packaging with Helm and Kustomize](https://www.internhack.in/roadmaps/tracks/devops/helm), [Continuous Integration and Delivery](https://www.internhack.in/roadmaps/tracks/devops/ci-cd-concepts)

**GitOps** applies the infrastructure-as-code idea to deployments: the desired state of every environment is stored in Git, and software agents continuously make reality match it.

### The four principles

1. **Declarative**: the whole system is described with manifests, Helm charts or Kustomize overlays.
2. **Versioned and immutable**: that description lives in Git, so every change has an author, a review and a history.
3. **Pulled automatically**: an agent inside the cluster pulls changes; CI no longer needs cluster admin credentials.
4. **Continuously reconciled**: the agent detects **drift** and corrects it, or at least alerts.

### Push CI vs pull GitOps

In push-based CD, the pipeline runs `kubectl apply` or `helm upgrade` and needs powerful credentials. In GitOps, CI builds and pushes an image, then updates an image tag in a **config repository**; the cluster agent does the rest. Rolling back becomes `git revert`.

### Repository layouts

- **App repo vs config repo**: keep source code and environment manifests separate so deploy history is clean.
- Directory per environment (`envs/dev`, `envs/prod`) with Kustomize overlays or Helm values files.
- **Promotion** is a pull request that copies a version from one environment folder to the next.
- Automated **image updaters** can open those pull requests for you.

### Limits

Secrets need a separate solution, ordering between resources needs care, and non-Kubernetes resources require extra tooling (Crossplane, Terraform controllers).

**Good enough to move on:** you can explain push vs pull deployment, design an app-plus-config repository layout for three environments, and describe how a rollback works in GitOps.

## Key concepts

- **OpenGitOps principles**
- **Push vs pull deployment**
- **App repo vs config repo**
- **Environment overlays and promotion**
- **Drift detection and self-healing**
- **Image update automation**

## Mini project

Create a config repository with base manifests and dev and prod Kustomize overlays for a sample app, and write the pull-request flow that promotes a new image tag from dev to prod.

## Check yourself

In a GitOps setup, someone runs kubectl edit on a production Deployment. What happens next, and why is that desirable?

## Free resources

- [OpenGitOps principles](https://opengitops.dev/) (CNCF OpenGitOps)
- [Kustomize documentation](https://kubectl.docs.kubernetes.io/) (Kubernetes SIG CLI)

Previous: [Deployment Strategies and Feature Flags](https://www.internhack.in/roadmaps/tracks/devops/deployment-strategies) · Next: [Argo CD](https://www.internhack.in/roadmaps/tracks/devops/argo-cd)

## More in GitOps and Secrets Management

- [GitOps Principles](https://www.internhack.in/roadmaps/tracks/devops/gitops-principles)
- [Argo CD](https://www.internhack.in/roadmaps/tracks/devops/argo-cd)
- [Flux](https://www.internhack.in/roadmaps/tracks/devops/flux)
- [Secrets Management Fundamentals](https://www.internhack.in/roadmaps/tracks/devops/secrets-management)
- [HashiCorp Vault](https://www.internhack.in/roadmaps/tracks/devops/vault)
- [SOPS, Sealed Secrets and External Secrets](https://www.internhack.in/roadmaps/tracks/devops/sops-external-secrets)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [DevOps Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/devops)
