Reputation: 5637
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?
Upvotes: 40
Views: 41786
Reputation: 91
You can use Move2Kube and do move2kube collect
with the Kubernetes cluster in context to get all kind versions supported by the cluster. It gives an ordered list of all versions supported by a kind in an order going from newest to oldest.
It will give you the following information:
apiVersion: move2kube.konveyor.io/v1alpha1
kind: ClusterMetadata
metadata:
name: IBM-IKS
spec:
storageClasses:
- default
- ibmc-block-bronze
- ibmc-block-custom
- ibmc-block-gold
- ibmc-block-retain-bronze
- ibmc-block-retain-custom
- ibmc-block-retain-gold
- ibmc-block-retain-silver
- ibmc-block-silver
- ibmc-file-bronze
- ibmc-file-bronze-gid
- ibmc-file-custom
- ibmc-file-gold
- ibmc-file-gold-gid
- ibmc-file-retain-bronze
- ibmc-file-retain-custom
- ibmc-file-retain-gold
- ibmc-file-retain-silver
- ibmc-file-silver
- ibmc-file-silver-gid
apiKindVersionMap:
APIService:
- apiregistration.k8s.io/v1
BGPConfiguration:
- crd.projectcalico.org/v1
BGPPeer:
- crd.projectcalico.org/v1
Binding:
- v1
BlockAffinity:
- crd.projectcalico.org/v1
CSIDriver:
- storage.k8s.io/v1
- storage.k8s.io/v1beta1
CSINode:
- storage.k8s.io/v1
- storage.k8s.io/v1beta1
CatalogSource:
- operators.coreos.com/v1alpha1
CertificateSigningRequest:
- certificates.k8s.io/v1beta1
ClusterInformation:
- crd.projectcalico.org/v1
ClusterRole:
- rbac.authorization.k8s.io/v1
- rbac.authorization.k8s.io/v1beta1
ClusterRoleBinding:
- rbac.authorization.k8s.io/v1
- rbac.authorization.k8s.io/v1beta1
ClusterServiceVersion:
- operators.coreos.com/v1alpha1
ComponentStatus:
- v1
ConfigMap:
- v1
ControllerRevision:
- apps/v1
CronJob:
- batch/v1beta1
- batch/v2alpha1
CustomResourceDefinition:
- apiextensions.k8s.io/v1
DaemonSet:
- apps/v1
Deployment:
- apps/v1
EndpointSlice:
- discovery.k8s.io/v1beta1
Endpoints:
- v1
Event:
- events.k8s.io/v1beta1
- v1
FelixConfiguration:
- crd.projectcalico.org/v1
GlobalNetworkPolicy:
- crd.projectcalico.org/v1
GlobalNetworkSet:
- crd.projectcalico.org/v1
HorizontalPodAutoscaler:
- autoscaling/v1
- autoscaling/v2beta1
- autoscaling/v2beta2
HostEndpoint:
- crd.projectcalico.org/v1
IPAMBlock:
- crd.projectcalico.org/v1
IPAMConfig:
- crd.projectcalico.org/v1
IPAMHandle:
- crd.projectcalico.org/v1
IPPool:
- crd.projectcalico.org/v1
Ingress:
- networking.k8s.io/v1
- networking.k8s.io/v1beta1
- extensions/v1beta1
IngressClass:
- networking.k8s.io/v1
- networking.k8s.io/v1beta1
InstallPlan:
- operators.coreos.com/v1alpha1
Job:
- batch/v1
KubeControllersConfiguration:
- crd.projectcalico.org/v1
Lease:
- coordination.k8s.io/v1beta1
- coordination.k8s.io/v1
LimitRange:
- v1
LocalSubjectAccessReview:
- authorization.k8s.io/v1
- authorization.k8s.io/v1beta1
MutatingWebhookConfiguration:
- admissionregistration.k8s.io/v1beta1
- admissionregistration.k8s.io/v1
Namespace:
- v1
NetworkPolicy:
- networking.k8s.io/v1
NetworkSet:
- crd.projectcalico.org/v1
Node:
- v1
Operator:
- operators.coreos.com/v1
OperatorGroup:
- operators.coreos.com/v1
PersistentVolume:
- v1
PersistentVolumeClaim:
- v1
Pod:
- v1
PodDisruptionBudget:
- policy/v1beta1
PodSecurityPolicy:
- policy/v1beta1
PodTemplate:
- v1
PriorityClass:
- scheduling.k8s.io/v1beta1
- scheduling.k8s.io/v1
RBACSync:
- ibm.com/v1alpha1
ReplicaSet:
- apps/v1
ReplicationController:
- v1
ResourceQuota:
- v1
Role:
- rbac.authorization.k8s.io/v1
- rbac.authorization.k8s.io/v1beta1
RoleBinding:
- rbac.authorization.k8s.io/v1
- rbac.authorization.k8s.io/v1beta1
Secret:
- v1
SelfSubjectAccessReview:
- authorization.k8s.io/v1
- authorization.k8s.io/v1beta1
SelfSubjectRulesReview:
- authorization.k8s.io/v1
- authorization.k8s.io/v1beta1
Service:
- v1
ServiceAccount:
- v1
StatefulSet:
- apps/v1
StorageClass:
- storage.k8s.io/v1
- storage.k8s.io/v1beta1
SubjectAccessReview:
- authorization.k8s.io/v1
- authorization.k8s.io/v1beta1
Subscription:
- operators.coreos.com/v1alpha1
TokenReview:
- authentication.k8s.io/v1
- authentication.k8s.io/v1beta1
ValidatingWebhookConfiguration:
- admissionregistration.k8s.io/v1beta1
- admissionregistration.k8s.io/v1
VolumeAttachment:
- storage.k8s.io/v1
- storage.k8s.io/v1beta1
Upvotes: 0
Reputation: 5637
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
Upvotes: 64
Reputation: 153
You can use a tool - kubepug as a pre-upgrade check to find out what changed in a given Kubernetes version if you were to upgrade your cluster to that version. Link - https://github.com/rikatz/kubepug
Upvotes: 1
Reputation: 144
For kubernetes-1.17.x (different format from what posted above)
for i in `kubectl api-resources | grep -v KIND | awk '{print $NF}'`;do kubectl explain ${i} | grep -e "KIND:" -e "VERSION:"; echo '----'; done
will show api for each kind
Upvotes: 3
Reputation: 441
I think kubectl api-versions
is a simpler alternative:
kubectl api-versions
admissionregistration.k8s.io/v1beta1
apiextensions.k8s.io/v1beta1
apiregistration.k8s.io/v1
apiregistration.k8s.io/v1beta1
apps/v1
apps/v1beta1
apps/v1beta2
authentication.k8s.io/v1
authentication.k8s.io/v1beta1
authorization.k8s.io/v1
authorization.k8s.io/v1beta1
autoscaling/v1
autoscaling/v2beta1
autoscaling/v2beta2
batch/v1
batch/v1beta1
certificates.k8s.io/v1beta1
coordination.k8s.io/v1
coordination.k8s.io/v1beta1
events.k8s.io/v1beta1
extensions/v1beta1
networking.k8s.io/v1
networking.k8s.io/v1beta1
node.k8s.io/v1beta1
policy/v1beta1
rbac.authorization.k8s.io/v1
rbac.authorization.k8s.io/v1beta1
scheduling.k8s.io/v1
scheduling.k8s.io/v1beta1
storage.k8s.io/v1
storage.k8s.io/v1beta1
v1
Upvotes: 29
Reputation: 61551
That would be the kubectl explain <resource>
command. For example for pods:
$ kubectl explain pod
KIND: Pod
VERSION: v1 <== API version
DESCRIPTION:
Pod is a collection of containers that can run on a host. This resource is
created by clients and scheduled onto hosts.
FIELDS:
apiVersion <string>
APIVersion defines the versioned schema of this representation of an
object. Servers should convert recognized schemas to the latest internal
value, and may reject unrecognized values. More info:
https://git.k8s.io/community/contributors/devel/api-conventions.md#resources
...
Similarly for deployments:
$ kubectl explain deploy
KIND: Deployment
VERSION: extensions/v1beta1 <== API Version
DESCRIPTION:
DEPRECATED - This group version of Deployment is deprecated by
apps/v1beta2/Deployment. See the release notes for more information.
Deployment enables declarative updates for Pods and ReplicaSets.
FIELDS:
apiVersion <string>
APIVersion defines the versioned schema of this representation of an
object. Servers should convert recognized schemas to the latest internal
value, and may reject unrecognized values. More info:
https://git.k8s.io/community/contributors/devel/api-conventions.md#resources
...
Also, here's the v1.12 API reference for example.
Upvotes: 14