kubectl: get apiVersion of a resource

John Zen
Feb 7, 2024

--

Kubernetes upgrade/deprecate/change apiVersion of different resources often. To know what are the apiVersion used:

kubectl get ${resource-kind} -A -o custom-columns="apiVersion:.apiVersion,Namespace:.metadata.namespace,Name:.metadata.name"

e.g. podsecuritypolicy

kubectl get podsecuritypolicy -A -o custom-columns="apiVersion:.apiVersion,Namespace:.metadata.namespace,Name:.metadata.name"

--

--