SOLVED - Rancher upgrade failed - no matches for kind "Issuer" in version "cert-manager.io/v1beta1"

Error: UPGRADE FAILED: current release manifest contains removed kubernetes api(s) for this kubernetes version and it is therefore unable to build the kubernetes objects for performing the diff. error from kubernetes: unable to recognize "": no matches for kind "Issuer" in version "cert-manager.io/v1beta1"

Error: UPGRADE FAILED: unable to build kubernetes objects from current release manifest: unable to recognize "": no matches for kind "Issuer" in version "certmanager.k8s.io/v1alpha1"

SOLUTION

You have to edit your latest Helm v3 config for for Rancher and replace cert-manager.io/v1beta1 with cert-manager.io/v1.

HOW TO

Open your Rancher Dashboard and go to Secrets in cattle-system namespace (Kind: Helm Release). And locate Secrets named sh.helm.release.v1.rancher.v*.

In my case I need to edit latest config version named sh.helm.release.v1.rancher.v7.

Apply this fix:

kubectl get secret sh.helm.release.v1.rancher.v7 -n cattle-system -o yaml > helm-rancher-config.yaml

kubectl get secrets sh.helm.release.v1.rancher.v7 -n cattle-system -o json | jq .data.release | tr -d '"' | base64 -d | base64 -d | gzip -d > helm-rancher-config-data-decoded.yaml

echo Choose your Cert Manager string to replace (v1alpha1 vs v1beta1)
sed -e 's/cert-manager.io\/v1beta1/cert-manager.io\/v1/' helm-rancher-config-data-decoded.yaml > helm-rancher-config-data-decoded-replaced.yaml

# sed -e 's/certmanager.k8s.io\/v1alpha1/cert-manager.io\/v1/' helm-rancher-config-data-decoded.yaml > helm-rancher-config-data-decoded-replaced.yaml

releaseData=$(cat helm-rancher-config-data-decoded-replaced.yaml | gzip | base64 | base64 | tr -d "\n")

sed 's/^\(\s*release\s*:\s*\).*/\1'$releaseData'/' helm-rancher-config.yaml > helm-rancher-config-final.yaml

kubectl apply -f helm-rancher-config-final.yaml -n cattle-system

Troubleshooting

In my case I need to remove all the older Secret versions and keep only the latest version, because Helm upgrade loads sh.helm.release.v1.rancher.v1 all the time.

Later I have found why - badly saved latest deployed version to v1. (Rancher Dashboard -> Apps & Marketplace -> Installed Apps -> Rancher -> view yaml)