#!/bin/bash set -x if [ -x "$(command -v kubectl)" ]; then echo 'kubectl is already installed.'; else curl -s -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"; curl -s -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"; if [ -x "$(command -v sha256sum)"]; then echo 'sha256sum is already installed.'; echo "$(cat kubectl.sha256) kubectl" | sha256sum --check; else echo "Install sha256sum to validate the kubectl binary but It is optional step"; fi chmod +x kubectl mkdir -p ~/.local/bin mv ./kubectl ~/.local/bin/kubectl export PATH=~/.local/bin:$PATH kubectl version --client; rm kubectl.sha256 fi