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 →
- Safest: create a new Deployment with a new name and the new selector, shift the Service, then remove the old one (PruneLast helps).
- If downtime is acceptable, annotate the Deployment with
argocd.argoproj.io/sync-options: Replace=true,Force=truefor one sync (delete and recreate), then remove the annotation. - 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.
More on Sync Behaviour, Waves & Hooks
A new release needs a database migration that must finish before the new pods start. How do you implement it in Argo CD?IntermediateYour app needs cert-manager's CRDs, an Issuer and then a Certificate, all in one Application. The first sync fails. What do you do?IntermediateAfter enabling `prune: true`, someone renames a folder and the next sync would delete a production StatefulSet and its PVCs. How do you prevent this class of incident?AdvancedYou want a smoke test to run after every deploy and mark the sync failed if it fails. How?BeginnerAn HPA scales your Deployment, but Argo CD with self-heal keeps resetting replicas to 2. What do you do?BeginnerA team wants Argo CD to deploy only during business hours, except for emergencies. How do you set it up?Beginner