Ashley
Ashley

Reputation: 1629

Command to query list of all objects/resources using a specific API version in kubernetes

We have an application running on EKS 1.21 and we are in the process of upgrading to EKS 1.22 since 1.21 will reach end of support in Feb 2023. I am trying to figure out a kubectl command or something similar that can query the entire cluster for any v1beta1 API versions that are deprecated and replaced by GA v1 as per :-

https://kubernetes.io/blog/2021/07/14/upcoming-changes-in-kubernetes-1-22/

https://docs.aws.amazon.com/eks/latest/userguide/update-cluster.html#update-1.22

https://kubernetes.io/docs/reference/using-api/deprecation-guide/#v1-22

Is there a comprehensive consolidated kubectl command that can be used to see if there is any YAML manifest in the cluster that still uses v1beta1?

Upvotes: 3

Views: 915

Answers (1)

P....
P....

Reputation: 18351

The below command would return the namespace, name, apiVersion, and all the resources in your cluster. You can pipe this with grep to filter wherever you want.

kubectl api-resources --no-headers  |while read type ignore; do kubectl get $type  -A -o go-template='{{range $index,$pod := .items}}{{(or .metadata.name  "-")}} {{(or .metadata.namespace "-")}} {{ (or .kind "-")}} {{ (or .apiVersion  "-") }} {{"\n"}}{{end}}'  2>/dev/null; done

Upvotes: 4

Related Questions