Skip to content

Instantly share code, notes, and snippets.

@paulwilljones
Forked from JulienBreux/aliases.sh
Created August 31, 2017 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulwilljones/9f7f8cf6407c95e6c90fe6476637b98a to your computer and use it in GitHub Desktop.
Save paulwilljones/9f7f8cf6407c95e6c90fe6476637b98a to your computer and use it in GitHub Desktop.
Kubernetes term aliases
# Used to run minikube shortly
alias mk="minikube"
# Used to run kubectl shortly
alias k="kubectl"
# Used to get ...
alias kg="kubectl get"
# Used to get all pods
alias kgp="kubectl get pods"
# Used to get all pods with watching
alias kgpw="watch kubectl get pods"
# Used to create a resource
kc() {
kubectl create -f $1
}
# Used to delete a resource
kd() {
kubectl delete -f $1
}
# Used to re-create a resource
# (Not replace or apply, juste re-create)
kr() {
kubectl delete -f $1
kubectl create -f $1
}
# Used to kill a pod now!
kpk() {
ns="default"
if [ -z "$2" ]; then
ns=$2
fi
kubectl delete pod $1 --grace-period=0 --force --namespace=$ns
}
# Used to exec in a pod
kpe() {
ns="default"
if [ -z "$3" ]; then
ns=$3
fi
kubectl exec -it $1 -c $2 --namespace=$ns
}
# Used to find a pod name
kpf() {
ns="default"
if [ -z "$2" ]; then
ns=$2
fi
kubectl get pods --namespace=$ns | grep $1 | awk '{print $1}'
}
# Used to display and follow pod logs
kpl() {
ns="default"
if [ -z "$3" ]; then
ns=$3
fi
kubectl logs $1 -c $2 --namespace=$ns -f
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment