Knowing the version of your Kubernetes cluster and its components is essential for maintaining and upgrading your system. Kubernetes provides several ways to retrieve version information, which can be useful for troubleshooting, compatibility checks, and planning upgrades.
Checking the Kubernetes API Server Version
To retrieve the version of the Kubernetes API server, you can use the kubectl version
command:
kubectl version
This will output the version information for both the client (your local kubectl
tool) and the server (the Kubernetes API server).
You can also get a more detailed overview of your Kubernetes cluster, including the version information, by using the kubectl cluster-info
command:
kubectl cluster-info
This will display the URL and version of the Kubernetes API server, as well as the addresses of other important components like the DNS server.
Checking the Kubelet Version
The Kubelet is the agent running on each node in the Kubernetes cluster, responsible for managing the lifecycle of pods. To check the version of the Kubelet, you can use the following command on a specific node:
ssh node01 kubelet --version
Replace node01
with the hostname or IP address of the node you want to check.
Ensuring Version Compatibility
When upgrading Kubernetes, it's important to ensure that all components are compatible with the target version. You can use the kubectl version
command to check the version compatibility between the client and server components:
kubectl version --short
This will display the client and server versions, allowing you to verify that they are compatible before proceeding with an upgrade.