Kubernetes - How to know latest supported API version

s g picture s g · Oct 9, 2018 · Viewed 9.2k times · Source

Is there a table that will tell me which set of API versions I should be using, given a k8s cluster version? Kubernetes docs always assume I always have a nice, up-to-date cluster (1.12 at time of writing) but platform providers don't always live on this bleeding edge so it can get frustrating quite quickly.

Better yet, is there a kubectl command I can run that will let me cluster tell me each resource type and its latest supported API version?

Answer

s g picture s g · Oct 9, 2018

For getting a list of all the resource types and their latest supported version, run the following:

for kind in `kubectl api-resources | tail +2 | awk '{ print $1 }'`; do kubectl explain $kind; done | grep -e "KIND:" -e "VERSION:"

It should produce output like

KIND:     Binding
VERSION:  v1
KIND:     ComponentStatus
VERSION:  v1
KIND:     ConfigMap
VERSION:  v1
KIND:     Endpoints
VERSION:  v1
KIND:     Event
VERSION:  v1
...

As @Rico mentioned, they key is in the kubectl explain command. This may be a little fragile since it depends on the format of the printed output, but it works for kubernetes 1.9.6

Also, the information can be gathered in a less efficient way from the kubernetes API docs (with links for each version) found here - https://kubernetes.io/docs/reference/#api-reference