# Error: UPGRADE FAILED: rendered manifests contain a resource that already exists. Unable to continue with update

- **ID:** `kubernetes/helm-upgrade-failed-drifted-resources`
- **Domain:** kubernetes
- **Category:** build_error
- **Error Code:** `K8S-HELM-004`
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Helm is trying to create a resource (e.g., a Deployment or Service) that already exists in the cluster but is not managed by the current release, often due to a previous failed install or manual creation.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| helm 3.10.0 | active | — | — |
| helm 3.11.0 | active | — | — |
| helm 3.12.0 | active | — | — |
| kubernetes 1.23 | active | — | — |
| kubernetes 1.25 | active | — | — |

## Workarounds

1. **Use `helm list -a` to check for existing releases in the namespace. If the resource belongs to a different release, delete that release with `helm delete <release-name> --purge` (Helm 2) or `helm uninstall <release-name>` (Helm 3).** (85% success)
   ```
   Use `helm list -a` to check for existing releases in the namespace. If the resource belongs to a different release, delete that release with `helm delete <release-name> --purge` (Helm 2) or `helm uninstall <release-name>` (Helm 3).
   ```
2. **Annotate the existing resource with the Helm release metadata to adopt it: `kubectl annotate <resource-type> <resource-name> meta.helm.sh/release-name=<release-name> meta.helm.sh/release-namespace=<namespace>`. Then retry the upgrade.** (75% success)
   ```
   Annotate the existing resource with the Helm release metadata to adopt it: `kubectl annotate <resource-type> <resource-name> meta.helm.sh/release-name=<release-name> meta.helm.sh/release-namespace=<namespace>`. Then retry the upgrade.
   ```

## Dead Ends

- **Delete the resource manually and rerun helm upgrade.** — This may cause data loss or service disruption if the resource is critical; also, the resource might be managed by another Helm release, causing conflicts. (50% fail)
- **Use `--force` flag with helm upgrade.** — The `--force` flag does not resolve ownership conflicts; it only forces pod restart. The error will persist. (90% fail)
