# error: error validating "deployment.yaml": error validating data: [ValidationError(Deployment.spec): unknown field "replicas" in io.k8s.api.apps.v1.DeploymentSpec]; if you choose to ignore these errors, turn validation off with --validate=false

- **ID:** `kubernetes/kubectl-apply-invalid-yaml-syntax`
- **Domain:** kubernetes
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

YAML manifest has a typo or wrong field name (e.g., 'replicas' instead of 'replicas'), causing API validation to reject it.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| kubectl v1.28 | active | — | — |
| kubectl v1.29 | active | — | — |
| kubectl v1.30 | active | — | — |

## Workarounds

1. **Correct the typo: change 'replicas' to 'replicas' in deployment.yaml and reapply: `kubectl apply -f deployment.yaml`.** (95% success)
   ```
   Correct the typo: change 'replicas' to 'replicas' in deployment.yaml and reapply: `kubectl apply -f deployment.yaml`.
   ```
2. **Use `kubectl explain deployment.spec.replicas` to verify correct field name and structure.** (90% success)
   ```
   Use `kubectl explain deployment.spec.replicas` to verify correct field name and structure.
   ```
3. **Validate YAML offline with `kubectl --dry-run=client -f deployment.yaml` before applying.** (85% success)
   ```
   Validate YAML offline with `kubectl --dry-run=client -f deployment.yaml` before applying.
   ```

## Dead Ends

- **Use --validate=false blindly to bypass validation** — Bypasses validation but the field is still invalid; API server will reject with a different error. (90% fail)
- **Rename the field to something else (e.g., 'count')** — Kubernetes API expects exact field names; renaming won't match the schema. (95% fail)
- **Delete and recreate the YAML file** — Recreating doesn't fix the typo; same error will occur. (85% fail)
