about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2017-09-15T15·52-0400
committerWilliam Carroll <wpcarro@gmail.com>2017-09-15T15·52-0400
commit658c41a54e3f2b9def4197ec68b0364b119c6f5e (patch)
tree51bf2cc880c61a5f2f6e192bdbe6b6d98a10408b
parent1f4006c72d128758bdce7265fba1c05e68b777ac (diff)
Add kubernetes aliases
-rw-r--r--aliases.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/aliases.sh b/aliases.sh
index 4d56755989be..742e09ff8406 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)"'