kubernetes, aws, amazon linux 2,

How to install Kubectl on Amazon Linux 2

Mar 14, 2022 · 1 min read · Post a comment

Installing the kubectl from the official Red Hat based distributions and adding it through the default yum packages will throw failure: repodata/repomd.xml from kubernetes: [Errno 256] No more mirrors to try. on Amazon Linux 2. So here I’m going to show you how to install kubectl on Amazon Linux 2 through curl.

Prerequisites

  • Amazon Linux 2
  • sudo privileges

Install Kubectl on Amazon Linux 2

Step 1. Download the latest stable version.

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

Step 2. Pull 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"

Step 3. Verify kubectl binary with the checksum file.

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

Step 4. Install kubectl.

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

Step 5. Verify installation.

kubectl version --client --output=yaml

Output:

clientVersion:
  buildDate: "2022-02-16T12:38:05Z"
  compiler: gc
  gitCommit: e6c093d87ea4cbb530a7b2ae91e54c0842d8308a
  gitTreeState: clean
  gitVersion: v1.23.4
  goVersion: go1.17.7
  major: "1"
  minor: "23"
  platform: linux/amd64

Conclusion

Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.