Find Deprecated API Resources used in a Kubernetes Cluster

Navratan Lal Gupta
Linux Shots
Published in
4 min readNov 13, 2022

--

Either its applications update or a clusters upgrade, from infrastructure to application layer, everything must be updated periodically to keep up with latest security issues, features and resolve bugs.

Kubernetes releases a new minor version approximately every 4 months (3 times a year). With every release, several APIs are promoted to stable from their beta versions and several APIs are removed.

We also need to keep our cluster up-to-date with Kubernetes releases to fix security and common bugs. But Kubernetes upgrade (especially production/live clusters) is not just the simple task to perform. With that comes lots of planning, testings and then after all the requirements are met, we move to next version of cluster.

In planning, We need to look into Kubernetes documentations and find out which APIs have been removed. Applications may breakdown, if it uses API resources which are going to be removed in next version of cluster. So, We need to find those APIs being used in our application and fix them before upgrading the cluster.

Looking into deployed resources in cluster and checking into their helm charts is very tedious task. It becomes more difficult when there are numbers of applications deployed on a cluster.

But, There is a very easy way to detect those resources. With a tool named, kube-no-trouble (Kube ? No trouble). In short, kubent. This tool is used to check whether you’re using any of the API versions which are going to be removed in upgraded version of your cluster and therefore should upgrade your workloads first, before upgrading your Kubernetes cluster.

Kubent Logo

How do we use it ? Lets see a demo here.

Why it works on my machine ?

I am using:

  1. Kubernetes cluster 1.23.14
  2. Master and worker nodes on Ubuntu 22.04
  3. Kubent 0.6.0
Cluster details

Demo:

  1. I will deploy older version of MetalLB (v0.10.3) and Ingress controller (1.1.1) on cluster for this demo which contains some deprecated APIs which are going to be removed in Kubernetes 1.25.
Install MetalLB using manifests
Install Ingress Nginx Controller using helm

2. Install Kubent tool on jumpbox or any machine from where you run kubectl command to manage cluster.

sh -c "$(curl -sSL https://git.io/install-kubent)"

This will download required binary and move to /usr/local/bin.

Install kubent

3. Run Kubent

Output of Kubent

By running kubent command, You should be able to see deprecated APIs which are going to be removed in future version. As in screenshot you can see PodSecurityPolicy named controller and speakerare used in resources and is going to be removed K8s 1.25.

Kubent can also be used to detect deprecated APIs used in manifest files before we deploy it on cluster. With just a simple flag -f or --filename .

kubent --filename manifest-file.yaml --cluster=false

I have added —cluster=false to make kubent ignore resources deployed on cluster and only check into manifest file provided.

Deprecated APIs used in manifest file

So that is it. I hope this will save some effort when you are upgrading your clusters. To check more details about it, Visit kubent’s github page here — https://github.com/doitintl/kube-no-trouble

If its helpful, Don’t forget to clap for this article. You may also share a cup of coffee with me on https://www.buymeacoffee.com/linuxshots or by scanning below QR code.

https://www.buymeacoffee.com/linuxshots

Thanks

Navratan Lal Gupta

Linux Shots

--

--

Navratan Lal Gupta
Linux Shots

I talk about Linux, DevOps, Kubernetes, Docker, opensource and Cloud technology. Don't forget to follow me and my publication linuxshots.