The kubectl api-versions
command in Kubernetes is used to retrieve the API versions that are available in the cluster. This information is crucial for understanding which resources and features are supported by the Kubernetes API server at any given time.
To begin exploring Kubernetes API versions, you can execute the following command:
kubectl api-versions
This command returns a list of API group versions supported by the Kubernetes API server. For example:
admissionregistration.k8s.io/v1 apiextensions.k8s.io/v1 apps/v1 ...
Each line represents an API group followed by its version. To verify the command’s execution and output, you can simply run it in your terminal or command prompt connected to a Kubernetes cluster.
Additionally, you can specify a particular API group to see its versions. For instance, to list API versions specifically for the core resources:
kubectl api-versions | grep core
This command filters and displays only the API versions related to core Kubernetes resources. Example output might include:
admissionregistration.k8s.io/v1 apps/v1 authentication.k8s.io/v1 ...
Furthermore, you can check the API versions for a specific resource type. For example, to view the API versions for Pods:
kubectl api-versions | grep pods
This command retrieves the API versions related to Pods specifically. Sample output could be:
apps/v1 v1 ...
If you’re interested in API versions related to custom resources, you can filter using “custom” as shown below:
kubectl api-versions | grep custom
This command lists the API versions associated with custom resources. Output may include entries like:
apiextensions.k8s.io/v1 custom.metrics.k8s.io/v1beta1 ...
For developers exploring newer Kubernetes features, retrieving alpha and beta versions is useful. Execute:
kubectl api-versions | grep beta
This command fetches API versions marked as beta, which are experimental or under development. Example output might look like:
admissionregistration.k8s.io/v1beta1 apps/v1beta1 ...
Additionally, if you’re managing CRDs (Custom Resource Definitions), check their supported API versions:
kubectl api-versions | grep crd
This command specifically lists API versions relevant to CRDs. Output could include:
apiextensions.k8s.io/v1 custom.metrics.k8s.io/v1beta1 ...
Lastly, for administrators needing information on deprecated API versions, use the following command:
kubectl api-versions | grep deprecated
This command retrieves API versions that are marked as deprecated. Example output may show:
extensions/v1beta1 ...
Each of these examples demonstrates how kubectl api-versions
can be utilized to explore and understand the Kubernetes API versions supported in your cluster.
Also check similar articles.
Understanding Kubernetes API Resources with kubectl api-resources
Generating Shell Completion Code with kubectl completion
Managing Kubernetes Annotations with kubectl annotate
Updating Kubernetes Labels with kubectl label
Building Kubernetes Customizations with kubectl kustomize
Discussion about this post