Rancher upgrades fails with "resource mapping not found for name" error due to deprecated api version for a resource
This document (000021213) is provided subject to the disclaimer at the end of this document.
Situation
The relevant error message below may appear when running the helm upgrade command to upgrade Rancher.
Examples:
helm upgrade rancher rancher-stable/rancher --namespace cattle-system -f values.yaml --version=2.X.X Error: UPGRADE FAILED: unable to build kubernetes objects from current release manifest: resource mapping not found for name: "rancher" namespace: "" from "": no matches for kind "Issuer" in version "cert-manager.io/v1alpha2"" ensure CRDs are installed first
helm upgrade rancher rancher-stable/rancher --namespace cattle-system -f values.yaml --version=2.X.X Error: UPGRADE FAILED: unable to build kubernetes objects from current release manifest: resource mapping not found for name: "rancher" namespace: "" from "": no matches for kind "Ingress" in version "networking.k8s.io/v1beta1"
Resolution
The helm-mapkubeapis plugin can be used to restore your release to a working state. This plugin reads Helm release data and replaces superseded APIs with their new versions or removes resources that refer to APIs that were completely removed from Kubernetes.
Note that Helm plugins are installed locally in the machine where the commands are run. Therefore, please make sure to run the installation steps on the same machine where you intend to run the cleanup steps.
Install helm-mapkubeapis
-
Ensure that Helm is installed by running `helm version`
You should see an output similar to the following:version.BuildInfo{Version:"v3.10.2", GitCommit:"50f003e5ee8704ec937a756c646870227d7c8b58", GitTreeState:"clean", GoVersion:"go1.18.8"}
-
Install the helm-mapkubeapis plugin:
helm plugin install https://github.com/helm/helm-mapkubeapis
Output should be similar to:
Downloading and installing helm-mapkubeapis v0.4.1 ... https://github.com/helm/helm-mapkubeapis/releases/download/v0.4.1/helm-mapkubeapis_0.4.1_linux_amd64.tar.gz Installed plugin: mapkubeapis
-
Check that the plugin was installed correctly:
helm mapkubeapis --help
Output should be similar to:
Map release deprecated or removed Kubernetes APIs in-place Usage: mapkubeapis [flags] RELEASE Flags: --dry-run simulate a command -h, --help help for mapkubeapis --kube-context string name of the kubeconfig context to use --kubeconfig string path to the kubeconfig file --mapfile string path to the API mapping file --namespace string namespace scope of the release
Clean up releases
-
Open your terminal of choice and make sure the Rancher management upstream cluster is accessible by running:
kubectl cluster-info
- Perform a dry run for the Rancher release in the cattle-system namespace to check the changes:
helm mapkubeapis --dry-run rancher --namespace cattle-system
Output should be similar to:
NOTE: This is in dry-run mode, the following actions will not be executed. Run without --dry-run to take the actions described below: Release 'rancher' will be checked for deprecated or removed Kubernetes APIs and will be updated if necessary to supported API versions. Get release 'rancher' latest version. Check release 'rancher' for deprecated or removed APIs... Found 1 instances of deprecated or removed Kubernetes API: "apiVersion: networking.k8s.io/v1beta1 kind: Ingress NOTE: This is in dry-run mode, the following actions will not be executed. Run without --dry-run to take the actions described below: Release 'rancher' will be checked for deprecated or removed Kubernetes APIs and will be updated if necessary to supported API versions. Get release 'rancher' latest version. Check release 'rancher' for deprecated or removed APIs... Found 1 instances of deprecated or removed Kubernetes API: "apiVersion: networking.k8s.io/v1beta1 kind: Ingress
- Perform a full run with helm:
helm mapkubeapis rancher --namespace cattle-system
Output should be similar to:Release 'rancher' will be checked for deprecated or removed Kubernetes APIs and will be updated if necessary to supported API versions. Get release 'rancher' latest version. Check release 'rancher' for deprecated or removed APIs... Found 1 instances of deprecated or removed Kubernetes API: "apiVersion: networking.k8s.io/v1beta1 kind: Ingress " Supported API equivalent: "apiVersion: networking.k8s.io/v1 kind: Ingress " Finished checking release 'rancher' for deprecated or removed APIs. Deprecated or removed APIs exist, updating release: rancher. Set status of release version 'rancher.v1' to 'superseded'. Release version 'rancher.v1' updated successfully. Add release version 'rancher.v2' with updated supported APIs. Release version 'rancher.v2' added successfully. Release 'rancher' with deprecated or removed APIs updated successfully to new version. Map of release 'rancher' deprecated or removed APIs to supported versions, completed successfully.
Re-run the helm upgrade command after all deprecated or superseded APIs are removed.
Additional Information
Command to get the available apiVersion for cert-manager
kubectl get --raw /apis/cert-manager.io | jq .
Disclaimer
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:000021213
- Creation Date: 25-Sep-2023
- Modified Date:01-Mar-2024
-
- SUSE Rancher
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com