# The Deployment is invalid: spec.selector: Invalid value: field is immutable

**Code:** `field is immutable` · **Category:** Kubernetes · **Seen on:** Kubernetes

You tried to change a field Kubernetes doesn’t allow to change after creation — Deployment selectors, Job templates, Service clusterIP, PVC storage class.

## 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

1. Delete and recreate the object (keep data volumes in mind)
2. Create it under a new name and switch traffic
3. For Helm, keep selector labels stable

## Detailed fix by platform

### Kubernetes

1. 

```bash
kubectl delete deployment web --cascade=orphan   # keep pods running
kubectl apply -f deployment.yaml
```


## How to diagnose

1. **Field** — Which path is named?
2. **Diff** — kubectl diff -f file.yaml

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/kubernetes/field-is-immutable)
