Interview Prep/GitOps & Argo CD/Sync Behaviour, Waves & Hooks

You must change a Deployment's label selector, which is immutable. How do you roll it out with Argo CD?

AdvancedScenarioSync Behaviour, Waves & Hooks
Answer

Situation read → Apply fails with field is immutable.

What I'd do →

  1. Safest: create a new Deployment with a new name and the new selector, shift the Service, then remove the old one (PruneLast helps).
  2. If downtime is acceptable, annotate the Deployment with argocd.argoproj.io/sync-options: Replace=true,Force=true for one sync (delete and recreate), then remove the annotation.
  3. Make sure the Service selector matches the new labels in the same change.

Why → Kubernetes forbids selector changes; you either recreate or run old and new side by side.

Interview tip → Say you would never leave Force=true on permanently.

All GitOps & Argo CD questions Roadmap: Argo CD (GitOps)

More on Sync Behaviour, Waves & Hooks