Kubernetes: Find deprecated API versions

2 min read | by Jordi Prats

On a Kubernetes cluster we might have deprecated versions of the object, so after updating it we might end up with something not properly working:

$ kubectl api-resources | grep Ingress\$
ingresses                         ing              extensions/v1beta1                     true         Ingress
ingresses                         ing              networking.k8s.io/v1                   true         Ingress

To make sure we are not going to face this issue, we can use kubepug (PreUpGrade). To install it we can also use it as a krew plugin, it's called deprecations:

$ kubectl krew install deprecations

You can check the current status with:

$ kubectl deprecations
RESULTS:
Deprecated APIs:

ComponentStatus found in /v1
   ├─ ComponentStatus (and ComponentStatusList) holds the cluster validation info. Deprecated: This API is deprecated in v1.19+
    -> GLOBAL: scheduler 
    -> GLOBAL: controller-manager 
    -> GLOBAL: etcd-0 

PodSecurityPolicy found in policy/v1beta1
   ├─ PodSecurityPolicy governs the ability to make requests that affect the Security Context that will be applied to a pod and container. Deprecated in 1.21.
    -> GLOBAL: aws-node-termination-handler 
    -> GLOBAL: eks.privileged 


Deleted APIs:

Ingress found in extensions/v1beta1
   ├─ API REMOVED FROM THE CURRENT VERSION AND SHOULD BE MIGRATED IMMEDIATELY!!
    -> OBJECT: pet2cattle-private namespace: pet2cattle
    -> OBJECT: pet2cattle-public namespace: pet2cattle

If we need to check the status once we update to a specific version we just need to specify it using the --k8s-version:

$ kubectl deprecations --k8s-version=v1.21.1

This way we will be able to see what needs to be fixed before even updating the cluster


Posted on 23/09/2021