Interview Prep/GitOps & Argo CD/Sync Operations, Hooks & Health

`one or more objects failed to apply, reason: Deployment.apps "web" is invalid: spec.selector: Invalid value: ...: field is immutable`.

BeginnerTroubleshootingSync Operations, Hooks & Health
Answer

Likely causes → Someone changed labels used in spec.selector (often via a chart upgrade or a new commonLabels in Kustomize). Selectors and some fields (Job spec.template, Service clusterIP) cannot be updated in place.

Diagnose → argocd app diff web shows the selector change.

Fix → Revert the selector change, or let Argo CD recreate just that resource: annotate it with argocd.argoproj.io/sync-options: Replace=true (or Force=true,Replace=true) for one sync. Expect a brief outage for that Deployment.

Prevent → Use labels with includeSelectors: false in Kustomize instead of commonLabels; review chart upgrades for selector changes.

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

More on Sync Operations, Hooks & Health