Skip to content

resource mapping not found: API version removed after the upgrade

Kubernetestested on kubeadm, Kubernetes v1.35, pluto

After a Kubernetes upgrade, kubectl apply fails on parts of the repository. The hint “ensure CRDs are installed first” is misleading: the manifests use API versions such as batch/v1beta1 that have been removed.

Symptom

kubectl apply -f repo/
echo "Exit-Code: $?"
deployment.apps/web unchanged
service/web unchanged
resource mapping not found for name: "aufraeumen" namespace: "demo" from
"repo/cronjob.yaml": no matches for kind "CronJob" in version "batch/v1beta1"
ensure CRDs are installed first
resource mapping not found for name: "web" namespace: "demo" from "repo/hpa.yaml":
no matches for kind "HorizontalPodAutoscaler" in version "autoscaling/v2beta2"
ensure CRDs are installed first
resource mapping not found for name: "alt" namespace: "demo" from "repo/pdb.yaml":
no matches for kind "PodDisruptionBudget" in version "policy/v1beta1"
ensure CRDs are installed first
Exit-Code: 1

The state afterwards is the dangerous part: web was applied, the other three were not. A pipeline leaves a half-updated namespace behind.

Diagnosis

Let pluto check against the target version – it lists every removed API and its replacement.

pluto detect-files -d repo --target-versions k8s=v1.37.0
echo "Exit-Code: $?"
NAME         KIND                      VERSION               REPLACEMENT      REMOVED   DEPRECATED   REPL AVAIL
aufraeumen   CronJob                   batch/v1beta1         batch/v1         true      true         true
web          HorizontalPodAutoscaler   autoscaling/v2beta2   autoscaling/v2   true      true         false
alt          PodDisruptionBudget       policy/v1beta1        policy/v1        true      true         true
Exit-Code: 4

Causes

REMOVED trueAPI version removed

Kubernetes removes beta APIs after a transition period. The cluster only knows CronJob as batch/v1 – for batch/v1beta1 it finds no mapping.

no target versionpluto without --target-versions

Without a target version, pluto checks against an old default and reports some APIs as not removed. Always check against the version you are upgrading to.

Fix

Convert the manifests to the new version with the kubectl convert plugin and apply again.
kubectl convert -f repo/pdb.yaml --output-version policy/v1 > repo/pdb.neu.yaml
kubectl convert -f repo/hpa.yaml --output-version autoscaling/v2 > repo/hpa.neu.yaml
kubectl convert -f repo/cronjob.yaml --output-version batch/v1 > repo/cronjob.neu.yaml
mv repo/pdb.neu.yaml repo/pdb.yaml
mv repo/hpa.neu.yaml repo/hpa.yaml
mv repo/cronjob.neu.yaml repo/cronjob.yaml
pluto detect-files -d repo --target-versions k8s=v1.37.0
kubectl apply -f repo/
There were no resources found with known deprecated apiVersions.
cronjob.batch/aufraeumen created
horizontalpodautoscaler.autoscaling/web created
poddisruptionbudget.policy/alt created
deployment.apps/web unchanged
service/web unchanged

Don't: Hunt for CRDs. Run pluto in the CI pipeline instead – its exit code is not 0 as soon as removed APIs appear, so the pull request fails before it reaches the cluster.

▶
Break it yourself and find it – free
Kubernetes Day 2, Day 4: find and convert removed APIs before the upgrade breaks them – with pluto and kubectl convert.
Go to day 4 →

FAQ

What does kubectl convert do with the status block?

It adds an empty status block. It does no harm but does not belong in the Git repository – delete it before committing.

What about Helm releases on old APIs?

Helm stores the rendered manifests as a secret. pluto detect-helm finds releases with removed APIs before they can no longer be upgraded.

Related error patterns

More