Guides

Find removed APIs before a Kubernetes upgrade

Why kubectl won't show the deprecated API versions that break a Kubernetes upgrade, where they really hide, and how to find them in every cluster at once.

Updated

Every few releases, Kubernetes removes old API versions. The upgrade itself goes fine, and then the next helm upgrade or kubectl apply fails with no matches for kind "Ingress" in version "extensions/v1beta1". The time to find those is before you upgrade.

Why kubectl doesn't show them

The obvious check doesn't work. The API server stores each object once and converts it to whatever version you ask for, so kubectl get ingress -o yaml shows networking.k8s.io/v1 even if your Helm chart still says extensions/v1beta1. The cluster is fine; it's the things that write to the cluster that break.

Old API versions hide in:

  • Helm release manifests. Helm stores the manifest it last applied. If that uses a removed version, the next upgrade of that release fails. Check one with helm get manifest <release>.
  • kubectl's last-applied record. The kubectl.kubernetes.io/last-applied-configuration annotation keeps the version the file was written in, and the next kubectl apply of that file fails.
  • Managed fields. Each tool that writes an object records the API version it used, under metadata.managedFields.
  • Manifests in Git and CI, which the cluster never sees until you apply them.

The API server also counts requests to deprecated APIs since the last restart:

kubectl get --raw /metrics | grep apiserver_requested_deprecated_apis

That tells you something is calling an old API, not what or where.

What was removed, and when

Removed inAPI versionsUse instead
1.16Deployment, DaemonSet, ReplicaSet in extensions/v1beta1, apps/v1beta1, apps/v1beta2apps/v1
1.22Ingress in extensions/v1beta1 and networking.k8s.io/v1beta1networking.k8s.io/v1
1.22CustomResourceDefinition apiextensions.k8s.io/v1beta1, admission webhooks admissionregistration.k8s.io/v1beta1v1 of each
1.25CronJob batch/v1beta1, PodDisruptionBudget policy/v1beta1batch/v1, policy/v1
1.25PodSecurityPolicy policy/v1beta1Removed; use Pod Security Admission
1.26HorizontalPodAutoscaler autoscaling/v2beta2autoscaling/v2
1.27CSIStorageCapacity storage.k8s.io/v1beta1storage.k8s.io/v1
1.29, 1.32FlowSchema and PriorityLevelConfiguration flowcontrol.apiserver.k8s.io/v1beta2, v1beta3flowcontrol.apiserver.k8s.io/v1

The full list is in the Kubernetes deprecated API migration guide.

With Klystiq

The Upgrade check looks where old versions really hide, in every open context at once.

  1. Open the clusters you're about to upgrade.
  2. Open Upgrade check and pick the target Kubernetes version.
  3. Read the list: each object that still uses an API the target removes, where it was found (Helm release, last-applied record, or the tool that last wrote it, from managed fields), and the version to use instead.

The cluster's own controllers are left out of the managed-fields check, so you only see what you or your tools wrote. It covers APIs removed from 1.16 to 1.32.

Check your manifests too

The upgrade check reads what's in the cluster. For the YAML, Kustomize or Helm charts in your repository, use Local manifests: compare a folder with a running cluster and it flags any API version that the cluster's Kubernetes version, or either of the next two, removes. It doesn't apply anything.

Open-source command-line tools such as Pluto and kube-no-trouble also scan manifests and Helm releases if you'd rather run a check in CI.

The Checks docs have the details.

Try it on your own clusters.

Download Klystiq, point it at the kubeconfig you already have, and see all of your clusters in one window. Your kubeconfig has been through enough; Klystiq only reads it. Free for personal use; a license for work.