Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thomaspeitz/afcfe700e9013627e55ef7c823c9e19c to your computer and use it in GitHub Desktop.
Save thomaspeitz/afcfe700e9013627e55ef7c823c9e19c to your computer and use it in GitHub Desktop.
kubectl aliases
for c in staging production infra thomas
do
alias k${c:0:1}="kubectl --context ${c}"
for ns in default monitoring kube-system "nginx-ingress" oauth "cert-manager"
do
shortcut=""
namespace=""
if [ "$ns" != "default" ]
then
shortcut=${ns:0:1}
namespace="--namespace ${ns}"
fi
alias k${c:0:1}${shortcut}="kubectl --context ${c} $namespace"
alias k${c:0:1}${shortcut}gp="kubectl --context ${c} $namespace get po"
alias k${c:0:1}${shortcut}l="kubectl --context ${c} $namespace logs"
alias k${c:0:1}${shortcut}e="kubectl --context ${c} $namespace exec -it"
alias k${c:0:1}${shortcut}p="kubectl --context ${c} $namespace port-forward"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment