Install and Set Up kubectl

Install and Set Up kubectl on Linux

Install kubectl binary with curl on Linux

  1. Download the latest release with the command:

    curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
    
  2. Validate the binary (optional)

Download the kubectl checksum file:

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

Validate the kubectl binary against the checksum file:

echo "$(<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
  1. Test to ensure the version you installed is up-to-date:

    kubectl version --client
    
  2. Install kubectl

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

Last change: Tue, 03 Aug 2021 10:25 PM UTC