Install Kubectl on an On-Prem Red Hat Linux 8.7
Context
Kubectl is a tool that could be used to facilitate Kubernetes learning and practice. It is a command line tool which you may use to run Kubernetes commands against a cluster. You may use Kubectl to view logs, manage a cluster, and deploy applications.
Note: Keeping your kubectl install version as close to the version of your Kubernetes cluster. Using latest compatible version avoids unforeseen issues and complications.
Logistics
- Install kubectl on local on-prem Red Hat Linux
- Good to have access to root or use credentials that have sudo privileges
- Server has access to the internet
- Know if your Linux is x86-64 or ARM64 (Appendix A has a list of ARM64 based commands to download and install kubectl)
Types of Installs
There are 3 ways to install kubectl:
- Using curl
- Using native package management (such as yum)
- Using other package management (Homebrew on Linux)
We will be using curl ON X86-64
Steps
Download the latest release of kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" DevOps- Steps to Install kubectl/media/image1.png)
Validate the binary (option but recommended)
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256" DevOps- Steps to Install kubectl/media/image2.png)
Validate the kubectl binary against the checksum file
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check DevOps- Steps to Install kubectl/media/image3.png)
valid shows as OK, if invalid sha256 exits as non-zero value prints output did not match type of warning shown below:
 DevOps- Steps to Install kubectl/media/image4.png)
Install Kubectl
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectlNote: There will not be any output on your screen
Validate Installation and version
kubectl version --client DevOps- Steps to Install kubectl/media/image5.png)
OR for detailed view of version
kubectl version --client --output=yaml DevOps- Steps to Install kubectl/media/image6.png)
ARM64 Based Commands
Download
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl"Download Binary & Validate
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl.sha256"Validate
echo "$(cat kubectl.sha256) kubectl" | sha256sum --checkInstall
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectlTest & Client Version
kubectl version --clientIn next series we will review and Install Kind which lets you run kubernetes on your local computer and requires Dockers or Podman to be installed as well.
Happy learning!