Last active
February 15, 2023 13:01
-
-
Save blairdrummond/c147d67f78028f84f8b56a57dea337b5 to your computer and use it in GitHub Desktop.
install kubernetes tools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Works with "darwin" and "linux" | |
OS := $(shell uname | tr '[:upper:]' '[:lower:]') | |
ARCH := $(shell uname -m) | |
# Create a local bin | |
BIN := /usr/local/bin | |
# Most of the binaries just grab the latest version. | |
# For better, or for worse! | |
TERRAFORM_VERSION := 1.0.6 | |
BINARIES := kubectl k9s kind yq kubectx helm kustomize doctl terraform vault | |
all: install-jq install-unzip $(BINARIES) | |
install: install-jq $(BINARIES) | |
mkdir -p $(BIN) | |
for f in $^; do \ | |
sudo mv $$f $(BIN)/$$f; \ | |
done | |
install-unzip: | |
unzip -v || sudo apt install unzip | |
# Hardcoded to 1.6 | |
jq: | |
if test "$(OS)" = "linux"; then \ | |
curl -L -o jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 ; \ | |
else \ | |
curl -L -o jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64 ; \ | |
fi | |
chmod +x jq | |
install-jq: jq | |
sudo mv ./jq /usr/local/bin | |
kubectl: | |
curl -LO "https://dl.k8s.io/release/$$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/$(OS)/amd64/kubectl" | |
chmod +x kubectl | |
k9s: | |
export PATH=$$PATH:$$(pwd); \ | |
VERSION=$$(curl -s https://api.github.com/repos/derailed/k9s/releases/latest | jq -r .tag_name); \ | |
curl -L https://github.com/derailed/k9s/releases/download/$$VERSION/k9s_$(OS)_x86_64.tar.gz \ | |
-o $@.tar.gz | |
tar -xf $@.tar.gz $@ && rm -rf $@.tar.gz | |
kind: | |
export PATH=$$PATH:$$(pwd); \ | |
VERSION=$$(curl -s https://api.github.com/repos/kubernetes-sigs/kind/releases/latest | jq -r .tag_name); \ | |
curl -L -o kind https://github.com/kubernetes-sigs/kind/releases/download/$$VERSION/kind-$(OS)-amd64 | |
chmod +x kind | |
yq: | |
export PATH=$$PATH:$$(pwd); \ | |
VERSION=$$(curl -s https://api.github.com/repos/mikefarah/yq/releases/latest | jq -r .tag_name); \ | |
curl -L -o yq https://github.com/mikefarah/yq/releases/download/$$VERSION/yq_$(OS)_amd64 | |
chmod +x yq | |
kubectx: | |
export PATH=$$PATH:$$(pwd); \ | |
VERSION=$$(curl -s https://api.github.com/repos/ahmetb/kubectx/releases/latest | jq -r .tag_name); \ | |
curl -L -o $@.tar.gz https://github.com/ahmetb/kubectx/releases/download/$$VERSION/kubectx_$${VERSION}_$(OS)_x86_64.tar.gz | |
tar -xf $@.tar.gz $@ && rm -rf $@.tar.gz | |
helm: | |
export PATH=$$PATH:$$(pwd); \ | |
VERSION=$$(curl -s https://api.github.com/repos/helm/helm/releases/latest | jq -r .tag_name); \ | |
curl -L -o helm.tar.gz https://get.helm.sh/helm-$${VERSION}-$(OS)-amd64.tar.gz | |
tar -xf helm.tar.gz && rm helm.tar.gz | |
mv $(OS)-amd64/helm . && rm -rf $(OS)-amd64 | |
kustomize: | |
export PATH=$$PATH:$$(pwd); \ | |
VERSION=$$(curl -s https://api.github.com/repos/kubernetes-sigs/kustomize/releases | jq -r 'first(.[]|select(.name | startswith("kustomize")) | .tag_name)' | awk -F '/' '{print $$2}'); \ | |
curl -L -o kustomize.tar.gz https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F$${VERSION}/kustomize_$${VERSION}_$(OS)_amd64.tar.gz | |
tar -xf $@.tar.gz $@ && rm -rf $@.tar.gz | |
doctl: | |
export PATH=$$PATH:$$(pwd); \ | |
VERSION=$$(curl -s https://api.github.com/repos/digitalocean/doctl/releases/latest | jq -r .tag_name | sed 's/^v//'); \ | |
curl -L https://github.com/digitalocean/doctl/releases/download/v$${VERSION}/doctl-$${VERSION}-$(OS)-amd64.tar.gz \ | |
-o $@.tar.gz | |
tar -xf $@.tar.gz $@ && rm -rf $@.tar.gz | |
terraform: | |
curl -L https://releases.hashicorp.com/terraform/$(TERRAFORM_VERSION)/terraform_$(TERRAFORM_VERSION)_$(OS)_amd64.zip \ | |
-o $@.zip | |
unzip $@.zip && rm -f $@.zip | |
vault: | |
VERSION=$$(curl -s https://api.github.com/repos/hashicorp/vault/releases/latest | jq -r .tag_name | sed 's/^v//'); \ | |
curl -L -o vault.zip https://releases.hashicorp.com/vault/$${VERSION}/vault_$${VERSION}_$(OS)_$(ARCH).zip | |
unzip $@.zip && rm -f $@.zip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment