Interview Prep/Kubernetes/Deployments and rollouts

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 →

  1. Detect drift with kubectl diff -f manifests/ in CI
  2. Adopt GitOps with Argo CD or Flux and enable self-heal/prune so Git is the source of truth
  3. Restrict edit and patch for humans through RBAC, with break-glass access that is audited
  4. Use server-side apply with field managers so ownership is explicit
  5. 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".

All Kubernetes questions Roadmap: Kubernetes core

More on Deployments and rollouts