Перейти к содержимому

Kubernetes version как узнать

  • автор:

Sorry, you have been blocked

This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.

What can I do to resolve this?

You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.

Cloudflare Ray ID: 7a253d8898d422f5 • Your IP: Click to reveal 88.135.219.175 • Performance & security by Cloudflare

How to Check Kubernetes Version

Published: August 19, 2020 by AuthorShane Rainville | Reading time: 1 minute

Learn how to use the kubectl cli to check which version of Kubernetes your clusters are running, and the version of Kubernetes each node is running.

Cluster Version

The simplest way of checking a cluster’s Kubernetes version is to use the kubectl version command. This command will output information for the kubectl client and the Kubernetes cluster.

The Server Version is the version of Kubernetes your cluster is running. You can the Major version, the minor version, as well as the Git version. The latter includes the bug fix.

In the example above, we can see that the Kubernetes cluster the command was ran against is running version 1.18.6. We can also see that our client is ahead of the cluster with version 1.18.8.

Node Version

To check which version each node is running we use the kubectl get nodes command. The output will list all of a cluster’s nodes and the version of Kubernetes each one is running.

Kubectl Version: How To Check Your K8s Version

In this guide, we highlight the kubectl version command and provide an actionable example alongside helpful context.

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.

Node Version

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:

NAME STATUS ROLES AGE VERSION
minikube Ready control-plane,master 29d v1.23.3
minikube-m02 Ready <none> 10m v1.23.3

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”.

Final Thoughts

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.

Check Kubernetes Cluster Version [5 Methods]

In this tutorial I will share multiple methods and commands to check Kubernetes Cluster Version in a Kubernetes Cluster.

Method-1: Check Kubernetes Cluster version using kubectl

The simplest way to check kubernetes cluster version would be using kubectl command. You can execute kubectl version to display long list of detail information related to Kubernetes Cluster (Both Server and Client):

We can trim the output only to get the Server and Client version using:

In case you only need the client version then you can execute:

Check Kubernetes Cluster Version [5 Methods]

You can also get the output in JSON format using kubectl version -o json command as shown below:

Method-2: Check Kubernetes Cluster version using kubeadm

We can use kubeadm upgrade plan command to check the Kubernetes Cluster version. Now this may not be the best command when you plan to check the cluster version in an automated way but it does gives you quiet detailed information of your existing cluster version:

For example, here I have executed kubeadm upgrade plan on a Cluster:

As you can see, it gives you a detailed list of information of all the different component version used in your Kubernetes Cluster.

On this cluster, kubectl shows following cluster version:

On a different cluster which was already running on the latest available version:

As you can see here, since the cluster was already on the latest available version we were not given any upgrade plan and the output was much shorted compared to previous cluster.

On this cluster, the kubectl version is as follows:

Method-3: Check Kubernetes Cluster version using kubectl get nodes command

We can check the Kubernetes Cluster Nodes version using kubectl get nodes command which will list all the available worker nodes along with the kubectl version on those nodes:

For example on this Kubernetes Cluster, my worker nodes and control plane are on 1.21.0 version:

For example on this Kubernetes Cluster, my worker nodes and control plane are on 1.18.8 version:

Similarly on this Kubernetes Cluster, my control plane and worker nodes are on 1.22.2 version:

Method-4: Check Kubernetes Cluster version using kubectl proxy command

We can get detailed information about any Kubernetes Cluster using kubectl proxy command. This command will basically create a proxy server which you can also refer as an application level gateway between the localhost (i.e. control plane) and the Kubernetes API Server. Next we can query the API server to get complete detail about the respective Kubernetes Cluster which will also display the cluster version:

From one terminal, execute the following command:

Check Kubernetes Cluster Version [5 Methods]

Now from another terminal execute curl http://localhost:8001/version -k as shown below:

Here you can get the Major and Minor version of your Kubernetes Cluster.

Method 5: Check Kubernetes Cluster version using kubelet command

The kubelet is the primary node agent that runs on each node. We can also check the version of kubelet on the control plane node to determine the Kubernetes Cluster version.

For example, here I have provide the kubelet version output from different clusters:

Summary

In this tutorial we covered different methods which can be used to check Kubernetes Cluster version. You can use these methods to automate your scripts or jobs. I can understand if you get confused wondering that there are so many components inside the cluster so which method would be the best reliable way. In my option you can use the kubectl command from Method 1 which gives you short and crisp information. You may also use kubeadm upgrade plan which gives you a very detailed information about your cluster and the installed component version.

Lastly I hope the steps from the article to check Kubernetes Cluster version was helpful. So, let me know your suggestions and feedback using the comment section.

References

Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

Капельница от запоя — облегчение за 15–20 минут