Skip to content

Expert · GitOps, platform engineering and DevOps careers · topic 50 of 53 · 30 min

GitOps and platform engineering

Explanation

GitOps keeps the desired state of your systems in Git and lets an agent in the cluster, such as Argo CD or Flux, pull it and keep the cluster matching it. Changes and rollbacks become pull requests and git reverts. Platform engineering builds an internal developer platform with golden paths, so every team can ship safely without reinventing pipelines.

What is GitOps?

GitOps is a way of running systems where Git is the single source of truth. The desired state (what should be running: Kubernetes manifests, Helm values, image tags) lives in a Git repository. A software agent compares that desired state with what is actually running and fixes any difference. Nobody changes production by hand; they change Git, and the agent does the rest.

The OpenGitOps project describes four principles:

  1. Declarative: you describe what you want ("3 replicas of image canteen-api:3f9c2ab"), not the steps to get there.
  2. Versioned and immutable: the desired state is stored in Git, so every change has an author, a review and a history.
  3. Pulled automatically: an agent fetches the desired state; nobody needs to push it into the cluster.
  4. Continuously reconciled: the agent keeps comparing and correcting, not just once at deploy time.

Push versus pull

Push-based deployPull-based GitOps
Who applies changesThe CI job runs kubectl apply or helm upgradeAn agent inside the cluster (Argo CD or Flux)
Cluster credentialsStored in CI, outside the clusterStay inside the cluster; CI only needs Git access
Manual changes in the clusterStay until the next deploy, unnoticedShown as drift, and can be reverted automatically
Audit trailCI logsGit history and pull request reviews

Argo CD and Flux are the two best-known GitOps tools, and both are graduated CNCF (Cloud Native Computing Foundation) projects. Argo CD has a web dashboard that many teams like; Flux is a set of controllers that you mainly drive through Git and the command line.

Reconciliation, sync status and drift

Reconciliation is the loop that compares desired state (Git) with live state (the cluster). In Argo CD an application is Synced when they match and OutOfSync when they differ. Drift is a difference caused by something other than Git, for example someone running kubectl scale at midnight to "fix" a slow service. With self-heal turned on, Argo CD changes the cluster back to what Git says.

yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: canteen-api-prod
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/acme/canteen-deploy.git
    targetRevision: main
    path: apps/canteen-api/overlays/prod
  destination:
    server: https://kubernetes.default.svc
    namespace: canteen
  syncPolicy:
    automated:
      prune: true      # delete resources that were removed from Git
      selfHeal: true   # undo manual changes (drift)
An Argo CD Application: watch this folder of this repository and keep the canteen namespace matching it.

Rollbacks with git revert

If a release goes wrong, you roll back by reverting the commit that changed the image tag. The agent sees the new commit and syncs the cluster back to the previous version. Git still tells the whole story: what changed, who rolled it back and when.

bash
git log --oneline -3 apps/canteen-api/overlays/prod
# 8c41d2e prod: canteen-api 3f9c2ab -> 7b0e915
git revert 8c41d2e
git push origin main      # Argo CD syncs back to 3f9c2ab within minutes
In GitOps a rollback is just another reviewed commit.

Environment promotion through pull requests

A common layout keeps application code in one repository and deployment configuration in another. CI builds the image, tags it with the commit SHA and updates the dev environment automatically. Moving the same image to staging and then production is a pull request that changes one line: the image tag in that environment's folder. The review and approval of that pull request is your change record.

output
canteen-deploy/
  apps/canteen-api/
    base/                 # Deployment, Service, shared settings
    overlays/
      dev/                # image tag updated by CI bot
      staging/            # promoted by pull request
      prod/               # promoted by pull request, needs 2 approvals
A Kustomize-style layout: one base, one small overlay per environment.

Platform engineering and internal developer platforms

When a company has 5 teams, each can build its own pipeline. With 50 teams, everyone re-solving CI, Kubernetes, secrets and dashboards wastes time and creates 50 different security levels. Platform engineering is the practice of a platform team building an internal developer platform (IDP): a set of self-service tools and paved roads that other teams use to build and run their services.

  • Golden path: the supported, recommended way to do a common job, such as "create a new Node.js service". It is the easy road, not a forced one.
  • Self-service templates: one form or command creates a repository with a Dockerfile, a CI pipeline, a Helm chart, dashboards and alerts already wired up.
  • Backstage: an open-source framework for building developer portals, created at Spotify and now a CNCF project. It offers a software catalogue (who owns which service), templates and documentation in one place.
Think of it like this: A platform team is like the facilities team of a big office. They do not do your work, but they make sure every desk has power, Wi-Fi and a working printer, so each team can get on with its real job. The golden path is the clearly signposted main corridor.

Measuring developer experience

Treat the platform as a product with internal customers, and measure whether it helps them. Useful measures: the DORA metrics (deployment frequency, lead time for changes, change failure rate and time to recover from a failed deployment), time for a new service to reach production, time for a new joiner to make a first deploy, how many teams use the golden path, and short regular surveys asking developers what slows them down.

Careful: Common mistakes: running kubectl edit in a GitOps-managed cluster (self-heal undoes it, or Git and the cluster quietly drift apart); putting plain Secrets in the Git repository (use Sealed Secrets or External Secrets); turning on prune without understanding that removing a file deletes the resource; building a platform nobody asked for. Fix: every change through Git, secrets from a secret manager, review deletions, and talk to your users first.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

GitOps and platform engineering · 1/7

GitOps Git = source of truth

GitOps means Git is the single source of truth for what should run in your systems.

Prefer a video by a teacher? Find free videos on “gitops argo cd tutorial platform engineering backstage explained” on YouTube ↗

In real life: Forty teams, one golden path, at a Bengaluru e-commerce company

An e-commerce company with about forty product teams had forty slightly different Jenkins pipelines and frequent "works in staging, breaks in prod" incidents. A five-person platform team built a Backstage template: one form creates a service repository with a Dockerfile, a GitHub Actions pipeline with scanning, a Helm chart and an Argo CD Application. Production changes became pull requests in a deploy repository. Within six months, the time to get a new service into production fell from about three weeks to two days, and rollbacks became a git revert that anyone on call could do safely.

Practice (0/3 done)

Task 1 · Question

In GitOps, a teammate runs kubectl scale to change replicas from 3 to 6 directly in production. Self-heal is on. What happens?

Task 2 · Code · Python

Write sync_status(desired, live). Both are dicts mapping an app name to its resources: a dict from a resource name (like "Deployment/api") to a dict of settings. Return a dict with one entry per app in desired: "Synced" if live has exactly the same resource names and every resource has the same settings, ignoring any "status" key; otherwise "OutOfSync". An app missing from live is "OutOfSync". Apps only in live are ignored.

Task 3 · Practice

Design the GitOps setup for a canteen API with dev, staging and prod environments. Describe the repositories, the folder layout, how a new image reaches each environment, who approves what, and how you roll back.

Quick quiz

Question 1

1.What is the key difference between push-based deployment and pull-based GitOps?

Question 2

2.Which two tools are graduated CNCF GitOps projects?

Question 3

3.What is a "golden path" in platform engineering?

Question 4

4.In a GitOps setup, how do you usually roll back a bad production release?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

What is the key difference between push-based deployment and pull-based GitOps?

Answer: In GitOps an agent inside the cluster pulls the desired state from Git, so CI does not need cluster credentials

The agent pulls and reconciles from inside the cluster; CI only writes to Git.

Which two tools are graduated CNCF GitOps projects?

Answer: Argo CD and Flux

Argo CD and Flux both reconcile Kubernetes clusters from Git.

What is a "golden path" in platform engineering?

Answer: A supported, recommended way to do a common task, such as creating a new service

Golden paths make the right way the easy way; they are offered, not forced.

In a GitOps setup, how do you usually roll back a bad production release?

Answer: git revert the commit that changed the image tag and let the agent sync

Git stays the source of truth, and the rollback is reviewed and recorded like any change.

What is the "pull model" in GitOps?Related

Answer: An agent in the cluster, such as Argo CD or Flux, pulls the desired state from Git and applies it

The cluster pulls from Git, so CI needs no cluster credentials and Git history is the deployment history.

From Deployment strategies, feature flags and GitOps

Why use npm ci instead of npm install in a pipeline?Related

Answer: It installs exactly the versions in package-lock.json, giving repeatable builds

npm ci does a clean install from the lock file, so CI uses the same versions every time.

From CI/CD: shipping every change safely

A Deployment wants 3 replicas. You delete one of its pods by hand. What happens?Related

Answer: A new pod is created to get back to 3

The ReplicaSet controller sees 2 of 3 and creates a replacement. That is self-healing.

From Why Kubernetes, and how a cluster works

Why do teams define required tags like owner and cost-centre?Related

Answer: To split the bill by team, find owners of resources and select resources for backups and policies

Tags drive cost reports, ownership and automation. AWS does not require them by default, so teams enforce them with policy.

From IaC in a team: reviews, pipelines and policy

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. 3 more topics in “GitOps, platform engineering and DevOps careers” before its exam: Capstone project: from commit to monitored production, DevOps certifications: which, when and how, DevOps careers and interviews in India.
  2. Module 12 exam: GitOps, platform engineering and DevOps careers · 12 questions · 20 min, without help. 4 topics of this module still to finish first.
  3. 53 topics left in the course before the final exam.

← Previous: Kubernetes security