Kubernetes is a popular container orchestration framework. It enables you to scale and manage large clusters of containers to deploy your applications efficiently to a large number users. Kubectl is a command-line tool that is used to manage your Kubernetes cluster.
In this guide, you will learn how to check the version of your Kubernetes resources using <terminal inline>kubectl version<terminal inline>.
Using Kubectl Version
<terminal inline>kubectl<terminal inline> provides a very simple command for viewing version details:
However, there are a number of ways you can use this command. Also, there are a few other things you might be looking for when viewing the version of your Kubernetes resources. Let’s take a look at them one by one.
Running kubectl version
You can view the cluster version using this command. Cluster version, here, refers to the version of the API server of your cluster. If you run the above command, you will receive a similar output:
The command returns two version details with quite verbose output.
The server version refers to the version of your Kubernetes API server. The client version refers to the version of your kubectl CLI.
Viewing Shorter Versions
You can switch to a cleaner version using the following command:
Now, you will receive a similar output:
Viewing the Client Version Only
You can also view only the client version by running the following command:
This will return only the <terminal inline>kubectl<terminal inline> CLI version to the output.
This is useful in situations when your CLI is not connected to an active Kubernetes API server. You can still access the CLI version without getting an error.
If you are looking for the version details of your nodes, you need to run the following command:
In the output that will be generated, you will see the version of the kubelet of each node listed against it:
For a more generalistic approach, you can append <terminal inline>-o yaml<terminal inline> to most commands to get a more detailed output, possibly containing version details that you are looking for. For instance, you can also view the version details of the kubelets of each node by running <terminal inline>kubectl get nodes -o yaml<terminal inline> and searching through the output for “kubelet”.
Kubernetes is, without a doubt, one of the most complex open-source projects. In this guide, you learned how to view the version details for a wide variety of resources and entities in Kubernetes.