kubectl-version
Display Kubernetes client and server versions
TLDR
Print the client and server version information for the current context
Print the client version only for the current context
Output the client and server version information for the current context in JSON
Output the client and server version information for the current context in YAML
SYNOPSIS
kubectl version [options]
PARAMETERS
--client
If set to true, only print the client version information, skipping the attempt to connect to the Kubernetes API server.
-o, --output=format
Output format. Can be one of: json, yaml, or short. The json and yaml formats provide structured output, while short prints a concise version number.
--short
If set to true, print just the version number. The exact output varies depending on whether an output format (like json or yaml) is also specified.
DESCRIPTION
The kubectl version command is a fundamental utility for understanding the state and compatibility of your Kubernetes environment. It provides crucial information about both the client (your local kubectl executable) and the server (the Kubernetes API server your kubectl is configured to connect to).
The client version indicates the version of the kubectl tool you are currently using. The server version reflects the version of the Kubernetes cluster's control plane. It's vital for these versions to be compatible, typically with the kubectl client being one minor version older or newer than the server, to avoid unexpected behavior or feature mismatches.
By default, the command outputs detailed information for both client and server, including the Git version, Git commit hash, build date, Go version used for compilation, and the platform. This information is invaluable for debugging, validating deployments, and ensuring that you are interacting with the cluster as expected.
CAVEATS
- To retrieve the server version, kubectl must be able to successfully connect to the configured Kubernetes cluster's API server. Network connectivity issues, incorrect kubeconfig settings, or insufficient RBAC permissions can prevent the server version from being displayed.
- Significant discrepancies between client and server versions (e.g., client being much newer or older than the server) can lead to unexpected behavior, command failures, or the inability to use certain features. It's generally recommended to keep client and server versions within one minor release of each other.
DETAILED OUTPUT FIELDS
When run without the --short flag or specific output formats, kubectl version provides detailed fields for both client and server. These include:
- GitVersion: The human-readable version string (e.g., v1.28.2).
- GitCommit: The full Git commit hash corresponding to the build.
- GitTreeState: Indicates if the Git working tree was clean or dirty at the time of the build.
- BuildDate: The date and time when the component was built.
- GoVersion: The version of Go programming language used to compile the component.
- Compiler: The Go compiler used.
- Platform: The operating system and architecture for which the component was built (e.g., linux/amd64).
HISTORY
The kubectl version command has been a staple in the Kubernetes ecosystem since its early days. As Kubernetes rapidly evolved, the need for a quick and reliable way to ascertain both the client tool's version and the cluster's version became critical for ensuring compatibility and troubleshooting. It's often one of the first commands a user runs when interacting with a new cluster or debugging issues.
SEE ALSO
kubectl cluster-info(1), kubectl config(1), kubectl get(1)


