# Error from server (Conflict): Operation cannot be fulfilled on pods "my-app-5d4f8b7c6-abcde": the object has been modified; please apply your changes to the latest version and try again

- **ID:** `cicd/kubectl-apply-pending`
- **Domain:** cicd
- **Category:** config_error
- **Error Code:** `K8S_CONFLICT`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

A Kubernetes resource update conflict occurs when two or more controllers or CI jobs try to modify the same resource concurrently, causing the second update to fail due to stale resourceVersion.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Kubernetes 1.28 | active | — | — |
| Kubernetes 1.29 | active | — | — |
| kubectl 1.29.0 | active | — | — |

## Workarounds

1. **Re-run the CI job after a short delay (e.g., 10 seconds) to allow the conflicting operation to complete and the resourceVersion to update.** (80% success)
   ```
   Re-run the CI job after a short delay (e.g., 10 seconds) to allow the conflicting operation to complete and the resourceVersion to update.
   ```
2. **Use `kubectl apply --server-side=true` which uses server-side apply to merge changes without conflict errors.** (90% success)
   ```
   Use `kubectl apply --server-side=true` which uses server-side apply to merge changes without conflict errors.
   ```
3. **Add a retry loop in the CI script: `for i in 1 2 3; do kubectl apply -f deployment.yaml && break || sleep 5; done`** (85% success)
   ```
   Add a retry loop in the CI script: `for i in 1 2 3; do kubectl apply -f deployment.yaml && break || sleep 5; done`
   ```

## Dead Ends

- **** — Deleting and recreating the resource manually; this causes downtime and may trigger cascading failures in dependent services. (60% fail)
- **** — Using `kubectl replace --force` which deletes and recreates the resource; this bypasses conflict detection but can delete other dependent objects. (70% fail)
- **** — Ignoring the error and retrying the same CI job without changes; the conflict persists because the resourceVersion hasn't been updated. (90% fail)
