Last active
March 16, 2017 02:03
-
-
Save leosunmo/ef451224314259c1d90f38814cd5441f to your computer and use it in GitHub Desktop.
Example of bashrc/zshrc kubectl function for multi-namespace/multi-region
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
# one function per cluster/region | |
function kus() { | |
case $1 in | |
# set namespace based on first arg | |
red) | |
kubectl --context=kube-prod-us --namespace=red ${@:2} | |
;; | |
green) | |
kubectl --context=kube-prod-us --namespace=green ${@:2} | |
;; | |
blue) | |
kubectl --context=kube-prod-us --namespace=blue ${@:2} | |
;; | |
#If no namespace is specified, pass on args to just the context | |
*) | |
kubectl --context=kube-prod-us $@ | |
esac | |
} | |
function keu() { | |
case $1 in | |
red) | |
kubectl --context=kube-prod-eu --namespace=red ${@:2} | |
;; | |
green) | |
kubectl --context=kube-prod-eu --namespace=green ${@:2} | |
;; | |
blue) | |
kubectl --context=kube-prod-eu --namespace=blue ${@:2} | |
;; | |
*) | |
kubectl --context=kube-prod-eu $@ | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment