This article walks you through the process of checking the version of Kubernetes. Here, we’ll show you the different methods to check the version of Kubernetes. We will guide you with the help of examples and demonstrate some sample outputs to show you what kind of output you should expect when you try these commands on your system. We will use the kubectl commands to check the Kubernetes versions, so make sure that you are familiar with the kubectl commands.
Get the Kubernetes Version with the “Kubectl Version” Command
Kubernetes is an open-source and free platform that allows you to run your services and applications. It automates the tasks and control resources for container-based applications. It is a favorite platform of developers to develop the container-based applications since it gives them the freedom to maintain microservices, reduce time to market, and seamlessly move from the development phase to production. Knowing the version of Kubernetes is important because most of the functionalities are not backward compatible.
Hence, it is essential to know the Kubernetes version to avoid any kind of compatibility issue. The quick, easy, and simple way to check the version of Kubernetes is to use the “version” command. The “kubectl” provides the “version” command to view the version of Kubernetes. There are many ways to get the Kubernetes version, but we start with the simplest method. Refer to the following command:
When you press enter, you will get a similar output to the one in the following:
The returned output by the “version” command contains a detailed information on both the client and the server. The “client version” presents the information of the kubectl CLI while the “server version” presents the information of the Kubernetes API server. Both versions contain the dictionary of all the details related to their version like major, minor, compiler, platform, etc.
However, it also shows a warning message that the version information is depreciated and suggests another method to check the version. As discussed previously, there are many ways to check the Kubernetes version but the most simple and easy to remember is the “kubectl version” command. We will demonstrate the other methods in the following sections for your convenience.
Get Only the Client Version of Kubernetes
As discussed previously, the “client version” refers to the version of the client that is installed. If you only want to see the version of the client you, can do that. There are different ways to check the version of the client but the simplest one is to use the built-in “–client” command. Here is the command that shows only the client version:
Upon executing this command, you will get the following output:
Get the Shorter Version of Kubernetes
As suggested in the previous output, the simple “version” command is replaced with the “—short” command. Let us check the version of the Kubernetes with the “—short” command. As can be seen in the previous output, the result shows a detailed version. But if you do not need the details and you are only concerned with the shortest version, you can use the “—short” command. Now, let us implement this and see the output:
The following output is generated for the short version:
As you can see, the kubectl returns the same client and server versions but is now in the shortest form and ignored all the minor details related to the version.
Get the Node Version
If you need to get the version of the nodes in your Kubernetes system, you can do that using the “get nodes” command. Here is the complete command to be used to get the version of nodes:
This lists down the kubectl version of all the nodes. See the following sample output:
Get the Kubernetes Version in JSON Format
Following the output of the “kubectl version” command, it suggests in getting the version in JSON or YAML form to get the complete version. Here, we demonstrate how to get the Kubernetes version in JSON format. The subsequent command is used to get the Kubernetes version in JSON format:
This returns the Kubernetes version in a structured JSON format. See the given sample output in the following snippet:
Get the Kubernetes Client Version in JSON Format
To only check the client version of Kubernetes in the JSON format, you can use the “json” parameter with the built-in “—client” command. The complete command to get only the client version is as follows:
The sample output for the client version is as follows:
Get the Kubernetes Client Version in JQ Format
The JQ can be combined with the JSON command to get the client version in JSON | JQ format. Use the following given command to get the desired output:
Upon executing this command, the following output is generated:
Get the Kubernetes Server Version in JQ Format
The same procedure can be followed to get the server version of Kubernetes in JSON | JQ format. The following given command can be used to get the version of the server:
A similar output is generated for the server version:
In case you only need to check the major and minor numbers from the version, you can specifically mention the “major” and “minor” parameters along with the previous command. See the following complete command:
This gives you the following result:
Get the Kubernetes Version in YAML Format
The other given suggestion in the “kubectl version” is to get the output in the YAML format. Let us learn how to get the Kubernetes version in YAML. Use the subsequent command to acquire the version in YAML format:
The following output is generated against this command:
In this guide, we learned how to get the Kubernetes version by demonstrating the different methods. We explored a wide range of methods and combinations of entities to get the version in different formats. By practicing these sample examples, you will be able to check the Kubernetes version according to your need.