Back to Tech Corner
DevOps

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

  1. Install kubectl on local on-prem Red Hat Linux
  2. Good to have access to root or use credentials that have sudo privileges
  3. Server has access to the internet
  4. 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:

  1. Using curl
  2. Using native package management (such as yum)
  3. Using other package management (Homebrew on Linux)

We will be using curl ON X86-64

Steps

  1. 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"
    Download kubectl output
  2. 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"
    Download kubectl.sha256 output
  3. Validate the kubectl binary against the checksum file

    echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
    Validation output showing OK

    valid shows as OK, if invalid sha256 exits as non-zero value prints output did not match type of warning shown below:

    Invalid validation output
  4. Install Kubectl

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

    Note: There will not be any output on your screen

  5. Validate Installation and version

    kubectl version --client
    kubectl version output

    OR for detailed view of version

    kubectl version --client --output=yaml
    kubectl version yaml output

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 --check

Install

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

Test & Client Version

kubectl version --client

In 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!