The Deployment is invalid: spec.selector: Invalid value: field is immutable
You tried to change a field Kubernetes doesn’t allow to change after creation — Deployment selectors, Job templates, Service clusterIP, PVC storage class.
Seen on:
Kubernetes
Meaning
Some fields are immutable because changing them would orphan or confuse existing objects. The fix is to delete and recreate the object (or create a new one with a different name). Helm upgrades fail this way when chart labels change.
Common causes
- Changing spec.selector (labels) of a Deployment/StatefulSet
- Editing a completed Job’s template
- Changing PVC storageClassName/size down, Service clusterIP or type-specific fields
⚡ Quick fix
- Delete and recreate the object (keep data volumes in mind)
- Create it under a new name and switch traffic
- For Helm, keep selector labels stable
Detailed fix by platform
Kubernetes
- bash
kubectl delete deployment web --cascade=orphan # keep pods running kubectl apply -f deployment.yaml
How to diagnose
- Field — Which path is named?
- Diff — kubectl diff -f file.yaml
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Kubernetes
- error converting YAML to JSON error converting YAML to JSON: yaml: line 12: did not find expected key
- is waiting to start Error from server (BadRequest): container "x" in pod "y" is waiting to start: ContainerCreating
- kubectl connection refused kubectl: The connection to the server localhost:8080 was refused — did you specify the right host or port?
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026