Kubectl setup

Hey,

I wrote up a setup script, to get my kubectl setup (in bash) running:

#!/usr/bin/env bash

# install krew
(
  set -x; cd "$(mktemp -d)" &&
  OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
  ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" &&
  KREW="krew-${OS}_${ARCH}" &&
  curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &&
  tar zxvf "${KREW}.tar.gz" &&
  ./"${KREW}" install krew
)

# make it available
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
echo 'export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"' >> ~/.bashrc

# add plugins
kubectl-krew install ctx ns view-secret viewnode rbac-view debug-shell

# add aliases
wget -O ~/.kubectl_aliases https://raw.githubusercontent.com/ahmetb/kubectl-aliases/master/.kubectl_aliases
source ~/.kubectl_aliases
echo '[ -f ~/.kubectl_aliases ] && source ~/.kubectl_aliases' >> ~/.bashrc

# missing ones
alias kgo="kubectl get -oyaml"
echo 'alias kgo="kubectl get -oyaml"' >> ~/.kubectl_aliases

# switch vars
echo 'export dco="--dry-run=client -oyaml"' >> ~/.bashrc
echo 'export dso="--dry-run=server -oyaml"' >> ~/.bashrc
export dco="--dry-run=client -oyaml"
export dso="--dry-run=server -oyaml"

And I thought I may ask for recommendations on tools, plugins or what not else might be useful to install alongside.

2 Likes

My handy tool is k9s

1 Like