ubuntu – Resolving WARNING about deprecated version information in kubectl (x86-64)

WARNING: This version information is deprecated and will be replaced with the 
output from kubectl version --short.  Use --output=yaml|json to get the full version.

Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.2", GitCommit:"7f6f68fdabc4df88cfea2dcf9a19b2b830f1e647", GitTreeState:"clean", BuildDate:"2023-05-17T14:20:07Z", GoVersion:"go1.20.4", Compiler:"gc", Platform:"linux/amd64"}

Below are the steps to download, validate, and install the kubectl binary on Linux systems.

  1. Download the latest version with the command:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
  1. Validate the binary (optional)

    Download the kubectl checksum file:

   curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"

Validate the kubectl binary against the checksum file:

echo "$(cat kubectl.sha256)  kubectl" | sha256sum --check

✅| If valid, the output is:

kubectl: OK

❌| If the check fails, sha256 exits with nonzero status and prints output similar to:

kubectl: FAILED
sha256sum: WARNING: 1 computed checksum did NOT match

Note: Download the same version of the binary and checksum.

  1. Install kubectl
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

Note:
If you do not have root access on the target system, you can still install kubectl to the ~/.local/bin directory:

chmod +x kubectl
mkdir -p ~/.local/bin
mv ./kubectl ~/.local/bin/kubectl
# and then append (or prepend) ~/.local/bin to $PATH
  1. Test to ensure the version you installed is up-to-date:
kubectl version --client

Or use this for detailed view of version:

kubectl version --client --output=yaml

⚡| More info: kubernetes.io/docs/tasks/tools/install-kubectl-linux/

Read more here: Source link