Interview's MateKubernetes
Interview's Mate

Kubernetes

K8s · Workloads · GitOps · Cloud

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Kubernetes topics
Lesson 93/ 160
05. Configuration, Packaging & GitOps

GitOps Principles & Pull-Based vs Push-Based Deployment

Treat Git as the source of truth and prefer pull-based cluster reconciliation.

BeginnerGitOps · Pull-Based · Source of Truth3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

Git is the signed blueprint register, and the GitOps agent is a site inspector who continuously corrects the building to the approved edition. The simple Kubernetes rule is: GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift.

Think of it like…

Git is the signed blueprint register, and the GitOps agent is a site inspector who continuously corrects the building to the approved edition.

Where you’ve seen it

A platform team reviews a promoted source revision and runs kubectl apply -f apps/; git diff --exit-code && kubectl get applications -A. Expected evidence: GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift. If the run instead shows this symptom, stop and restore the last known state: Giving CI direct cluster credentials can bypass review, and an agent with automatic pruning can interpret a deleted Git path as authorization to delete production data.

Words you’ll hear

GitOps
For this lesson, GitOps is the controlling idea: GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift.
Pull-Based
Pull-Based is the checkpoint; run kubectl apply -f apps/; git diff --exit-code && kubectl get applications -A and inspect the owner chain. Giving CI direct cluster credentials can bypass review, and an agent with automatic pruning can interpret a deleted Git path as authorization to delete production data.
Source of Truth
Source of Truth is the outcome to preserve; the cost is explicit: Pull-based control reduces cluster write credentials in CI and improves audit, but the reconciler, pruning policy, and secret path become critical infrastructure.
Verification evidence
The evidence command is kubectl apply -f apps/; git diff --exit-code && kubectl get applications -A. It connects the declaration to this behavior: Treat Git as the source of truth and prefer pull-based cluster reconciliation.

Visual diagram

Loading interactive diagram

Theory & deep dive

How GitOps reaches the intended state

Treat Git as the source of truth and prefer pull-based cluster reconciliation. GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift.

The concrete checkpoint is kubectl apply -f apps/; git diff --exit-code && kubectl get applications -A; compare the GitOps owner, Pull-Based state, and Source of Truth outcome instead of treating YAML acceptance as proof.

Verify Pull-Based, not only object creation

Run kubectl apply -f apps/; git diff --exit-code && kubectl get applications -A after the change and correlate the result with Events and the owning object. GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift.

Key takeaway: GitOps is implemented only when this invariant remains observable: GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift.

Pull-Based: failure boundary and production cost

Giving CI direct cluster credentials can bypass review, and an agent with automatic pruning can interpret a deleted Git path as authorization to delete production data. The prerequisite contract is concrete: GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift.

Pull-based control reduces cluster write credentials in CI and improves audit, but the reconciler, pruning policy, and secret path become critical infrastructure. A safe design limits blast radius, records the last good configuration, and uses kubectl apply -f apps/; git diff --exit-code && kubectl get applications -A as a deterministic rollback checkpoint.

Recover from Pull-Based drift

Capture the current state with kubectl apply -f apps/; git diff --exit-code && kubectl get applications -A, then correct the controlling manifest rather than patching a child object; the relevant divergence signal is specific: Giving CI direct cluster credentials can bypass review, and an agent with automatic pruning can interpret a deleted Git path as authorization to delete production data.

Key takeaway: Accept the trade-off consciously: Pull-based control reduces cluster write credentials in CI and improves audit, but the reconciler, pruning policy, and secret path become critical infrastructure.

How it works, step by step

Step 1 of 4
Source author

1. Choose the source of truth

Version the source and describe the review, render, and reconciliation boundary: GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift.

GitOps contract → owned state
Key numbers at this step
Goal
Treat Git as the source of truth and prefer pull-based cluster reconciliation.
Owner
GitOps

When to use it & trade-offs

What it is

Treat Git as the source of truth and prefer pull-based cluster reconciliation. GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift.

Why it matters: Giving CI direct cluster credentials can bypass review, and an agent with automatic pruning can interpret a deleted Git path as authorization to delete production data. The invariant at risk is specific: GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift. The quickest fact check before changing the design is kubectl apply -f apps/; git diff --exit-code && kubectl get applications -A.

When to reach for it

  • Use GitOps to enforce this invariant: GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift.
  • Use Pull-Based evidence from kubectl apply -f apps/; git diff --exit-code && kubectl get applications -A in reviews and incident timelines. Treat Git as the source of truth and prefer pull-based cluster reconciliation.
  • Choose the platform operator workflow route only when this cost is justified by governance or scale: Pull-based control reduces cluster write credentials in CI and improves audit, but the reconciler, pruning policy, and secret path become critical infrastructure.

When to avoid or be careful

  • Avoid assuming GitOps is complete after YAML submission; the required behavior is concrete: GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift.
  • Avoid treating the next symptom as random; check the owner and state with kubectl apply -f apps/; git diff --exit-code && kubectl get applications -A first: Giving CI direct cluster credentials can bypass review, and an agent with automatic pruning can interpret a deleted Git path as authorization to delete production data.
  • Avoid adopting a heavier platform wrapper before measuring its cost: Pull-based control reduces cluster write credentials in CI and improves audit, but the reconciler, pruning policy, and secret path become critical infrastructure.

Native, manual, and managed paths for GitOps

Versioned declarative source
Best for: Treat Git as the source of truth and prefer pull-based cluster reconciliation. A concrete incident check is kubectl apply -f apps/; git diff --exit-code && kubectl get applications -A.

Strengths: GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift.

Watch out: Pull-based control reduces cluster write credentials in CI and improves audit, but the reconciler, pruning policy, and secret path become critical infrastructure. Recovery must also recognize this signal: Giving CI direct cluster credentials can bypass review, and an agent with automatic pruning can interpret a deleted Git path as authorization to delete production data.

Imperative cluster edit
Best for: Quickly testing the Pull-Based assumption with kubectl apply -f apps/; git diff --exit-code && kubectl get applications -A; the expected invariant is: GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift.

Strengths: kubectl apply -f apps/; git diff --exit-code && kubectl get applications -A gives immediate feedback without first building a platform layer.

Watch out: A manual change can hide drift, and unlike GitOps, it does not make this symptom self-documenting: Giving CI direct cluster credentials can bypass review, and an agent with automatic pruning can interpret a deleted Git path as authorization to delete production data.

Platform operator workflow
Best for: Teams that need Source of Truth integrated with guardrails; the evidence path is kubectl apply -f apps/; git diff --exit-code && kubectl get applications -A.

Strengths: Platform controls can wrap this exact behavior in policy or dashboards: GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift.

Watch out: The added platform ownership buys value at this cost: Pull-based control reduces cluster write credentials in CI and improves audit, but the reconciler, pruning policy, and secret path become critical infrastructure.

Interview signals & numbers to know

When this topic comes up

  • Interview anchor: GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift.
  • Trace GitOps to Source of Truth through Pull-Based; the invariant is: GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift.
  • Recognize the symptom: Giving CI direct cluster credentials can bypass review, and an agent with automatic pruning can interpret a deleted Git path as authorization to delete production data.
  • Justify the cost: Pull-based control reduces cluster write credentials in CI and improves audit, but the reconciler, pruning policy, and secret path become critical infrastructure.
  • Verify with kubectl apply -f apps/; git diff --exit-code && kubectl get applications -A instead of only inspecting YAML.

Benchmarks & rules of thumb

1 -
reviewed source of truth
2 -
delivery modes to compare: push and pull
0 -
manual drift should remain after self-heal is enabled

Common mistakes & follow-ups

Common interview mistakes

  • Debugging only the child object misses the GitOps owner contract: GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift.
  • Ignoring this telltale condition leads to unrelated changes: Giving CI direct cluster credentials can bypass review, and an agent with automatic pruning can interpret a deleted Git path as authorization to delete production data.
  • Repeating kubectl apply -f apps/; git diff --exit-code && kubectl get applications -A without an owner for remediation wastes retry cost. Pull-based control reduces cluster write credentials in CI and improves audit, but the reconciler, pruning policy, and secret path become critical infrastructure.

Likely interviewer follow-ups

  • How would API output and runtime evidence prove this behavior: GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift?
  • Which owner object, logs, and Events would you inspect for this symptom-Giving CI direct cluster credentials can bypass review, and an agent with automatic pruning can interpret a deleted Git path as authorization to delete production data-?
  • At what threshold would this cost become unacceptable: Pull-based control reduces cluster write credentials in CI and improves audit, but the reconciler, pruning policy, and secret path become critical infrastructure?
Interview tip: Interview sequence: state the invariant, run kubectl apply -f apps/; git diff --exit-code && kubectl get applications -A, name the failure, then justify the cost. Invariant: GitOps stores desired configuration in version control, lets pull agents reconcile the cluster, and reports divergence so reviewed intent replaces imperative drift. Failure: Giving CI direct cluster credentials can bypass review, and an agent with automatic pruning can interpret a deleted Git path as authorization to delete production data. Cost: Pull-based control reduces cluster write credentials in CI and improves audit, but the reconciler, pruning policy, and secret path become critical infrastructure.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply GitOps Principles & Pull-Based vs Push-Based Deployment with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Managing Helm Repositories, Dependencies & OCI Registries
Next topic
Argo CD Architecture, Applications & ApplicationSets