Skip to content

Instantly share code, notes, and snippets.

@StephanX
Created June 26, 2017 18:58
Show Gist options
  • Save StephanX/bfad0735296fc4ee5f4f710fddeaaeca to your computer and use it in GitHub Desktop.
Save StephanX/bfad0735296fc4ee5f4f710fddeaaeca to your computer and use it in GitHub Desktop.
alias ku='kubectl'
alias kube='kubectl'
kubectl() {
if [[ $1 == "namespace" || $1 == "ns" ]] ; then
if [[ $2 ]] ; then
command kubectl config set-context $(kubectl config current-context) --namespace=${2} 2>&1 >>/dev/null
else command kubectl config view $(kubectl config current-context) | grep namespace | awk '{ print $2 }'
fi
elif [[ $1 == "desc" || $1 == "de" ]] ; then
shift
command kubectl describe "$@"
elif [[ $1 == "rm" || $1 == "del" ]] ; then
shift
command kubectl delete "$@"
elif [[ $1 == "ingresslogs" ]] ; then
command kubectl logs -f --namespace=default $(kubectl get pods --namespace=default | grep ingress-controller | awk '{ print $1 }') | grep -v 'change in configuration'
else
command kubectl "$@"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment