Created
April 10, 2017 03:03
-
-
Save YanhaoYang/be751c52e3636e62adc85de2ea0f7307 to your computer and use it in GitHub Desktop.
Generate `kubectl port-forward` cmds
This file contains hidden or 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
#!/bin/bash | |
pods=($(kubectl get po | grep -E 'api|db' | awk '{print $1}')) | |
for var in "${pods[@]}" | |
do | |
case "$var" in | |
*api*) | |
api_cmd="kubectl port-forward $var 3000:3000" | |
;; | |
*db*) | |
db_cmd="kubectl port-forward $var 5432:5432" | |
;; | |
esac | |
done | |
gnome-terminal \ | |
--tab -e "$api_cmd" \ | |
--tab -e "$db_cmd" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment