Symptoms While performing a helm upgrade, you may encounter an error indicating that the rendered manifests contain a resource that already exists. This is an actual error indicating a conflict due to a Custom Resource Definition existing in the system for a previous installation and not deleted appropriately.
In such a case, the conflicting resource would not appear in any of the general methodologies to find/remediate the list of available resources such as,
- helm list --all
- --skip-crds
- kubectl get crd
- --all-namespaces
Remediation Steps
Let’s say, you’re observing an issue while installing Ingress, where the error message clearly indicates that an object with the string Ingress already exists.
(base) ➜ ~ helm upgrade --install nginx-ingress --namespace nginx-ingress-namespace ingress-nginx/ingress-nginx Release "nginx-ingress" does not exist. Installing it now. Error: rendered manifests contain a resource that already exists. Unable to continue with install: IngressClass "nginx" in namespace "" exists and cannot be imported into the current release: invalid ownership metadata; annotation validation error: key "meta.helm.sh/release-name" must equal "nginx-ingress": current value is "ingress-nginx"; annotation validation error: key "meta.helm.sh/release-namespace" must equal "nginx-ingress-namespace": current value is "ingress-nginx-ns"
In such a case, review the cluster role and the respective binding associated with it.
Step-1: (base) ➜ ~ kubectl get clusterrole | grep ingress ingress-nginx 2023-06-22T04:22:49Z Step-2: (base) ➜ ~ kubectl get clusterrolebinding | grep ingress ingress-nginx ClusterRole/ingress-nginx
Note: Review the date of creation returned in the output to ensure that we are deleting the conflicting ones and then proceed with the deletion using the following commands.
(base) ➜ ~ kubectl delete clusterrole ingress-nginx clusterrole.rbac.authorization.k8s.io "ingress-nginx" deleted (base) ➜ ~ kubectl delete clusterrolebinding ingress-nginx clusterrolebinding.rbac.authorization.k8s.io "ingress-nginx" deleted
After the successful deletion, the helm upgrade would go through without any issues.