Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
useful kubectl shortcuts
# put in $HOME/.bash_k8s.rc
# . $HOME/bash_k8s.rc
# podlog <any pod name substring>
function podlog() {
kubectl get pods -o name | grep $1 | cut -d / -f 2 | head -n1 | xargs kubectl logs $2
}
# exec a command in a pod, defaults to bash
function podssh() {
pod=`kubectl get pods -o name | grep $1 | cut -d / -f 2 | head -n1`
shift 1
cmd=${@:-bash}
kubectl exec -it $pod -- $cmd
}
# get a list of pods
function pods() {
kubectl get pods
}
# get a list of services
function svcs {
kubectl get services
}
# describe something
function kdes() {
kubectl describe $*
}
# get cluster info
alias kinfo="kubectl cluster-info"
# shortcut to kubectl
alias k="kubectl"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.