KubernetesCIII · GitOps IntroductionGitOps
GitOps vs imperative — the operational comparison
What you'll learn
- Distinguish GitOps (pull) from imperative (push) cluster management
- Apply the trade-offs (security, audit, drift, recovery)
- Recognise when imperative management is appropriate
- Apply the operational discipline of preferring GitOps for production
Prerequisites
Verified against Kubernetes 1.34.x · kubeadm 1.34.x · kubectl 1.34.x · etcd 3.6.x · CoreDNS 1.11.x · containerd 1.7.x / 2.x · 2026-08-16
GitOps (pull) and imperative (push) cluster management are the two operational models. This lesson walks the differences, the trade-offs, when each is appropriate, and the operational discipline.
The two models
flowchart LR
A["Imperative: push"] --> B["CI / developer laptop"]
B -->|kubectl apply| C[Cluster]
D["GitOps: pull"] --> E[Git repository]
E -->|controller in cluster pulls| F[Cluster]
The two models:
- Imperative (push). A CI pipeline or developer
laptop runs
kubectl applyagainst the cluster. The cluster receives the manifests; the push is external. - GitOps (pull). A controller in the cluster pulls the manifests from Git. The cluster is the active party; Git is the source.
The trade-offs
flowchart LR
A[Imperative model] --> B[+ Fast feedback loop]
A --> C[- No audit trail]
A --> D[- Drift invisible]
A --> E[- Recovery requires backup]
A --> F[- Cluster API must be exposed]
G[GitOps model] --> H[+ Audit trail in Git]
G --> I[+ Drift detected and corrected]
G --> J[+ Recovery from Git]
G --> K[+ No external cluster access]
G --> L[- More complex setup]
G --> M[- Slower feedback loop]
The trade-offs:
Imperative model:
- Pros: Fast feedback loop; simple setup; good for development.
- Cons: No audit trail; drift invisible; recovery requires backup; cluster API must be exposed.
GitOps model:
- Pros: Audit trail in Git; drift detected and corrected; recovery from Git; no external cluster access.
- Cons: More complex setup; slower feedback loop; controller is a critical component.
When imperative is appropriate
Imperative management is appropriate for:
- Development environments. Fast feedback is more important than audit trail.
- One-off debugging. Applying a debug Pod or scaling a Deployment for investigation.
- Emergency fixes. When the GitOps controller is down and an urgent change is needed.
- Bootstrap. Initial cluster setup before GitOps is installed.
Production clusters should prefer GitOps; imperative should be the exception, not the rule.
The hybrid model
flowchart LR
A[Hybrid model] --> B[GitOps for production manifests]
A --> C[Imperative for debugging and bootstrap]
A --> D[GitOps selfHeal reverts imperative changes]
The hybrid: GitOps for production manifests, imperative for debugging and bootstrap.
- Production manifests are managed via Git (Argo CD, Flux).
- Debug Pods, one-off scaling, emergency fixes are applied imperatively.
- The GitOps controller’s selfHeal reverts the imperative changes after the debugging is done.
The hybrid balances operational agility (imperative for ad-hoc) with discipline (GitOps for production).
Quiz
Knowledge check · 4 questions
Q1. What does the push model make harder than the pull model?
Q2. A push-based pipeline detects configuration drift as part of its normal operation.
Q3. Restore a broken production image while the GitOps controller itself is down, without leaving drift behind.
`checkout` in `prod-app` is serving 500s from a bad image and the revert commit was merged 20 minutes ago. Argo CD cannot apply it: `argocd-application-controller-0` is in CrashLoopBackOff after a controller upgrade, and `argocd app get checkout` reports a last sync 55 minutes old. The Deployment still references `registry.example.com/checkout:2.4.1`.
Q4. Name the four situations in which imperative change is appropriate on a cluster that is otherwise GitOps-managed.
Passing score: 75%. Answers are checked in this browser.
The operational discipline
GitOps vs imperative in production rests on five non-negotiable elements:
- GitOps for production. Production manifests are managed via Git; no imperative changes.
- Imperative for debugging. Debug Pods, scaling, emergency fixes are allowed imperatively.
- selfHeal enabled. The GitOps controller reverts imperative changes to production manifests.
- Audit trail. Every GitOps change is a Git commit; every imperative change is logged in audit logs.
- Review imperative changes. Emergency imperative changes should be reviewed after the fact; the operator must justify the change.
GitOps is the discipline for production. Imperative is the exception, not the rule.