'List Kubernetes resources by apiVersion

Is there a easy way to list all kubernetes objects related to an API version? Lets say, API version apps/v1beta1 is getting deprecated and I want to know if I have any objects in my cluster using this version, how can I find such objects?



Solution 1:[1]

you can do something similar like this

kubectl get pod -o=custom-columns=NAME:.metadata.name,API-version:.metadata.owner_references[].api_version

by using kubectl just print respective data and api version

Solution 2:[2]

To list Kubernetes resource versions use this command:

kubectl api-resources

And if the you know what resource you are searching for then just filter it from the list using grep:

kubectl api-resources | grep the_resource_name_you_want

In the below example we search for the api version of 'persistentvolumes' resource:

kubectl api-resources | grep persistentvolumes

Result:

deployments     deploy    apps/v1     true         Deployment

There are additional options to get the resource version:

Use the official documentation:

The official and updated with the newest versions is in the Kubernetes API documentation

The left navigation bar lists the resources, click on one & the version is the first row of the page.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Harsh Manvar
Solution 2