Created
October 17, 2018 18:39
-
-
Save srevenant/e396f42318b6532821853ca602c7ad97 to your computer and use it in GitHub Desktop.
kubectl aliases for bashrc
This file contains 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
kube-env() { | |
local env=$1 | |
local ns=${2:-apz} | |
[ ! $env ] && { | |
echo "KUBE_ENV =$KUBE_ENV" | |
echo "KUBE_NAMESPACE=$KUBE_NAMESPACE" | |
echo "Envs: p1 d1" | |
echo "Namespaces: (run kubectl get namespaces)" | |
return 0 | |
} | |
export KUBECONFIG=~/.kube/ice-eks-$env.yml | |
export AWS_PROFILE=icentris-$env | |
export KUBE_ENV=$env | |
export KUBE_NAMESPACE=$ns | |
} | |
alias kc-env=kube-env | |
alias kce=kube-env | |
kc() { | |
local ns='' | |
if [ "x$1" != "x-n" ]; then | |
ns="-n $KUBE_NAMESPACE" | |
fi | |
printf " \033[34m kube-env $KUBE_ENV $KUBE_NAMESPACE\033[0m\n" 1>&2 | |
printf "\033[32m>>> kubectl $ns $*\033[0m\n\n" 1>&2 | |
kubectl $ns "$@" | |
} | |
kclog() { | |
kc logs --tail 100 -f $1 | |
} | |
kcsh() { | |
local container=$1 | |
local shell=$2 | |
if [ ! $shell ]; then | |
shell=/bin/bash | |
fi | |
kc exec -it $container -- $shell | |
} | |
kcls() { | |
local type=${1:-pods} | |
shift | |
kc get $type "$@" | |
} | |
kcdesc() { | |
local type=${1:-pod} | |
shift | |
kc describe $type "$@" | |
} | |
kcapp() { | |
local app=$1 | |
local type=${2:-pods} | |
shift | |
shift | |
kcls "$type" --selector=app==$app | |
} | |
kcclient() { | |
local client=$1 | |
local type=${2:-pods} | |
shift | |
shift | |
kcls "$type" --selector=client==$client | |
} | |
kctenant() { | |
local tenant=$1 | |
local type=${2:-pods} | |
shift | |
shift | |
kcls "$type" --selector=tenant==$tenant | |
} | |
kube-env d1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment