Kubernetes has deprecated api versions periodically with major changes in their v1.16 and current release v1.22 Old APIs will be deprecated in few releases and eventually removed.
Kubernetes cluster needs to be upgraded to latest version whenever CVEs are found. We will need a progressive plan to identify and fix deprecated apis. If you try to apply resource with removed apiVersion, deployment will fail trying to identify the version. This article will go over steps to identify and update apiVersion before we upgrade Kubernetes cluster version.
Identify deprecated APIs
You could check the cluster for available api extensions. Kubectl will provide you with first matching extension and could potentially confuse. There are various tools available to identify deprecated version with lots of options. We will discuss about couple here
Pluto is an tool provided by Fairwinds to find deprecated kubernetes apiVersion in your code repositories and helm releases. You can download latest tool release from their repository. Note: this tool not available for windows. Find installation steps in their documentation page.
Detect charts files for deprecated apis available in a folder
pluto detect-files -d application/chartsfolder
Detect deprecated apis in helm release
pluto detect-helm -owide
Kubent (kube no trouble) is another utility tool that identifies deprecated k8s apis. This tool looks for deprecated api is cluster as well in addition files and helm release. You can control where to scan using flags cluster, helm2 / helm3.
./kubent
Updating apiVersion - Above mentioned tools will identify deprecated apis, after identifying we need to fix by updating to required apiVersion. You will need to update apiVersion in your source code repositories to required version. To update deployed helm release we will use mapkubeapis plugin. This updates helm release metadata in-place by removing old apiVersion and creating new revision with updated apiVersion.
Install plugin
helm plugin install https://github.com/hickeyma/helm-mapkubeapis
Update release
use –namespace <> for HELMv2
helm mapkubeapis v2-oldapi
Re-run pluto / kubent utility tools to identify if old apiVersions are updated. You could provide Kubernetes version to target specific version. Kubernetes cluster can now be updated without causing any failure.
Including tools to identify and update Kubernetes resource apiVersion removes lot of manual work and errors that could be introduced. It facilitates smooth Kubernetes cluster upgradation.
Comments are closed.