Skip to content

Instantly share code, notes, and snippets.

@suresh-sendinblue
Last active November 23, 2023 09:14
Show Gist options
  • Save suresh-sendinblue/5aa22df7168c349a766bfb15a785e2c5 to your computer and use it in GitHub Desktop.
Save suresh-sendinblue/5aa22df7168c349a766bfb15a785e2c5 to your computer and use it in GitHub Desktop.
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment