Skip to content

Instantly share code, notes, and snippets.

@tariq1890
Last active November 13, 2024 16:23
Show Gist options
  • Save tariq1890/4e46cf5fdeae193a6015ddad00a750e2 to your computer and use it in GitHub Desktop.
Save tariq1890/4e46cf5fdeae193a6015ddad00a750e2 to your computer and use it in GitHub Desktop.
Kubernetes Productivity Tools Install Script
#!/bin/bash
# Run this script if you want to install essential k8s productivity tools.
# This script has been tested on both macOS and Linux
#
# Please ensure you have done the following before executing this script
# i) Make the script executable: chmod +x <script-name>.sh
# ii) Run the script as root. sudo sh <script-name>.sh OR sudo ./<script-name>.sh
#
# Suggestions for improvements are always welcome!
set -xe
KUBECTX_VERSION=${KUBECTX_VERSION:-"v0.9.5"}
STERN_VERSION=${STERN_VERSION:-"v1.31.0"}
K9S_VERSION=${K9S_VERSION:-"v0.32.5"}
OS_ARCH=$(uname -m)
OS=$(uname)
OS_NAME=$(uname | tr '[A-Z]' '[a-z]')
case "${OS_ARCH##*-}" in \
x86_64 | amd64) ARCH='amd64' ;; \
ppc64el | ppc64le) ARCH='ppc64le' ;; \
aarch64 | arm64) ARCH='arm64' ;; \
*) echo "unsupported architecture" ; exit 1 ;; \
esac;
if [ "$EUID" -ne 0 ]
then
echo "Please run as root"
exit
fi
# download and install kubectx
curl -fsSL -o kubectx_${KUBECTX_VERSION}_${OS_NAME}_${OS_ARCH}.tar.gz \
https://github.com/ahmetb/kubectx/releases/download/${KUBECTX_VERSION}/kubectx_${KUBECTX_VERSION}_${OS_NAME}_${OS_ARCH}.tar.gz
tar -xvzf kubectx_${KUBECTX_VERSION}_${OS_NAME}_${OS_ARCH}.tar.gz -C /usr/local/bin/
rm kubectx_${KUBECTX_VERSION}_${OS_NAME}_${OS_ARCH}.tar.gz
# download and install kubens
curl -fsSL -o kubens_${KUBECTX_VERSION}_${OS_NAME}_${OS_ARCH}.tar.gz \
https://github.com/ahmetb/kubectx/releases/download/${KUBECTX_VERSION}/kubens_${KUBECTX_VERSION}_${OS_NAME}_${OS_ARCH}.tar.gz
tar -xvzf kubens_${KUBECTX_VERSION}_${OS_NAME}_${OS_ARCH}.tar.gz -C /usr/local/bin/
rm kubens_${KUBECTX_VERSION}_${OS_NAME}_${OS_ARCH}.tar.gz
# download and install stern
curl -fsSL -o stern_${STERN_VERSION:1}_${OS_NAME}_${ARCH}.tar.gz \
https://github.com/stern/stern/releases/download/${STERN_VERSION}/stern_${STERN_VERSION:1}_${OS_NAME}_${ARCH}.tar.gz
tar -xvzf stern_${STERN_VERSION:1}_${OS_NAME}_${ARCH}.tar.gz -C /usr/local/bin
rm stern_${STERN_VERSION:1}_${OS_NAME}_${ARCH}.tar.gz
# download and install k9s
curl -fsSL -o k9s_${OS}_${ARCH}.tar.gz \
https://github.com/derailed/k9s/releases/download/${K9S_VERSION}/k9s_${OS}_${ARCH}.tar.gz
tar -xvzf k9s_${OS}_${ARCH}.tar.gz -C /usr/local/bin
rm k9s_${OS}_${ARCH}.tar.gz
# Download and Install Helm
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
helm version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment