LinuxCommandLibrary

kubectl-version

Display Kubernetes client and server versions

TLDR

Print the client and server version information for the current context

$ kubectl version
copy

Print the client version only for the current context
$ kubectl version --client
copy

Output the client and server version information for the current context in JSON
$ kubectl version [[-o|--output]] json
copy

Output the client and server version information for the current context in YAML
$ kubectl version [[-o|--output]] yaml
copy

SYNOPSIS

kubectl version [--client[=false]] [--short[=false]] [-o output]

PARAMETERS

--client[=false]
    Print client version only. Defaults to true without server connection, false otherwise

--output=string
    Output format: json|yaml|name|jsonpath|go-template|template|short

--short[=false]
    Print only version numbers (compact output)

DESCRIPTION

kubectl version prints version information for the kubectl client binary and the connected Kubernetes cluster's server (API server). This command is crucial for checking compatibility, as Kubernetes recommends clients within one minor version of the server to avoid issues.

By default, it shows detailed output including GitVersion, GitCommit, GitTreeState, BuildDate, GoVersion, Compiler, and Platform for both client and server. The client version is always available locally, while the server version requires a valid connection to the cluster via kubeconfig.

Use it before upgrades or troubleshooting to ensure versions align. Output can be customized for scripts or human-readable formats. It's a lightweight, read-only operation with no side effects on the cluster.

CAVEATS

Server version requires valid kubeconfig and cluster access; fails gracefully without connection. Inherits global kubectl options like --kubeconfig.

TYPICAL OUTPUT

Client Version: v1.28.0
Server Version: v1.27.3
(Short: v1.28.0+v1.27.3)

USE CASES

Verify compatibility pre-upgrade; script cluster health checks; debug connection issues.

HISTORY

Introduced in Kubernetes v0.1 (2014) as part of core kubectl tooling; stabilized in v1.0 (2015). Evolved with output formats and short mode in early releases.

SEE ALSO

kubectl(1)

Copied to clipboard