From 658c41a54e3f2b9def4197ec68b0364b119c6f5e Mon Sep 17 00:00:00 2001 From: William Carroll Date: Fri, 15 Sep 2017 11:52:42 -0400 Subject: [PATCH] Add kubernetes aliases --- aliases.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/aliases.sh b/aliases.sh index 4d5675598..742e09ff8 100644 --- a/aliases.sh +++ b/aliases.sh @@ -18,6 +18,33 @@ command -v tmux >/dev/null && alias tls='tmux list-sessions' || \ echo "Missing dependency (tmux). Failed to alias tls -> tmux list-sessions" +if command -v kubectl >/dev/null; then + # kubernetes aliases + alias kpods='kubectl get pods' + alias kdeploys='kubectl get deployments' + + # the following functions rely on gcloud being installed + if command -v gcloud >/dev/null; then + function kedit { + deployment=$1 + kubectl edit deployments $deployment + } + + function kswitch { + environment=$1 + gcloud container clusters get-credentials $environment + } + fi + + # kubernetes functions + function kush { + name=$1 + cmd=${2-/bin/bash} + kubectl exec -it $name -- $cmd + } +fi + + # git-specific aliases git config --global alias.recent 'for-each-ref --count=10 --sort=-committerdate refs/heads/ --format="%(refname:short)"' git config --global alias.today 'log --since=00:00:00 --all --no-merges --oneline --author="$(git config --get user.email)"'