Skip to content
tezvyn:

GitOps Principles: Your Repo as the Source of Truth

Source: opengitops.devEasyHow cards are made

GitOps Principles: Your Repo as the Source of Truth

GitOps treats infrastructure state like code, with your Git repo as the single source of truth. Automated agents pull declarative configs from the repo to reconcile the live system, making it ideal for Kubernetes.

Why it exists

Before GitOps, managing infrastructure was often a mix of manual commands, fragile scripts, and configuration drift. There was no single source of truth for what should be running, making rollbacks and audits difficult. GitOps was created to apply the rigor of software development (version control, review, history) to infrastructure management.

The mental model

Treat your infrastructure configuration as code. Your Git repository is the single source of truth for the desired state of your entire system. Any changes to the live system happen by making a commit to that repository, not by running commands manually. The system automatically makes itself match the repository.

How it works

GitOps is defined by four core principles. First, the system's desired state is described DECLARATIVELY, typically in configuration files like YAML. Second, this desired state is VERSIONED AND IMMUTABLE, stored in a Git repository with a full history. Third, software agents inside your environment automatically PULL the desired state from the source repo. Fourth, these agents CONTINUOUSLY RECONCILE the actual state of the system with the desired state, correcting any drift.

When to use it

GitOps is the de facto standard for continuous deployment in Kubernetes environments. It's ideal for any system that can be described declaratively, where you need a strong audit trail, easy rollbacks (just revert a Git commit), and an improved developer experience using familiar Git workflows.

When not to use it

GitOps is less suited for systems that aren't managed declaratively. If your deployment process relies on a sequence of imperative commands or manual steps that can't be codified, you can't fully adopt the model. The pull-based nature also means you must run and manage a GitOps agent (like Argo CD or Flux) within your infrastructure.

One canonical example

A developer wants to update a microservice's container image. Instead of running kubectl set image, they open a pull request to change the image tag in a YAML file in the Git repository. Once the PR is merged, a GitOps agent running in the Kubernetes cluster detects the change, pulls the new YAML, and automatically updates the deployment to match the new desired state.

Interview question

What is the primary mechanism by which GitOps ensures infrastructure consistency?

  • a.Developers manually apply configuration changes directly to the live system after approval.
  • b.A central CI/CD pipeline pushes configuration updates from Git to the infrastructure.
  • c.Automated agents continuously pull desired state from a Git repository and reconcile the live environment.Correct
  • d.Infrastructure state is regularly backed up to Git, allowing for manual restoration if drift occurs.
Why?

The card states that "software agents inside your environment automatically PULL the desired state from the source repo" and "these agents CONTINUOUSLY RECONCILE the actual state of the system with the desired state." Option B describes a push-based model, which is contrary to GitOps' pull-based nature.

Just read this? Test yourself on what you have been reading.

Read the original → opengitops.dev

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on gitops — each one lists the topics its interview covers.

See open roles