Deploys by `kubectl apply` in CI sometimes revert a hot-fix someone made with `kubectl edit`. How do you stop this drift?
IntermediateScenarioDeployments and rollouts
Answer
Situation read → Manual edits in prod are lost at the next pipeline run, and nobody knows why.
What I'd do →
- Detect drift with
kubectl diff -f manifests/in CI - Adopt GitOps with Argo CD or Flux and enable self-heal/prune so Git is the source of truth
- Restrict
editandpatchfor humans through RBAC, with break-glass access that is audited - Use server-side apply with field managers so ownership is explicit
- Alert when the live state differs from Git
Why → Client-side apply only merges the fields it knows about from the last-applied annotation, so out-of-band changes either persist silently or get overwritten.
Interview tip → Say "Git is the source of truth, and humans get read-only in prod".
More on Deployments and rollouts
You applied a new image tag and the rollout seems stuck at "1 out of 3 new replicas have been updated". What do you check first?BeginnerHow do you roll back a bad release and verify you are back on the previous version?BeginnerA rollout must never reduce capacity below current replicas. How do you configure the strategy?IntermediateYou need a blue/green deployment without a service mesh. How do you do it with plain Kubernetes?IntermediateHow would you do a canary release with only Deployments and a Service?IntermediateWhat is the difference between Recreate and RollingUpdate strategies and when would you pick Recreate?Beginner