GitOps Principles & Pull-Based vs Push-Based Deployment
Treat Git as the source of truth and prefer pull-based cluster reconciliation.
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 -Aand 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
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.
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.
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.
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.
How it works, step by step
Step 1 of 41. 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.
- 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 -Ain 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 -Afirst: 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
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.
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.
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 -Awithout 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?
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
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.