Skip to content

Instantly share code, notes, and snippets.

@tcotav
Created June 22, 2017 23:11
Show Gist options
  • Save tcotav/75de4c358dee6af0cab077e51e409b80 to your computer and use it in GitHub Desktop.
Save tcotav/75de4c358dee6af0cab077e51e409b80 to your computer and use it in GitHub Desktop.
kubectl aliases
# put in .bashrc on linux, .bash_profile on osx
alias kc="kubectl"
# get all specified resource types in current namespace
alias kls="kubectl get svc,pods,rc,deployments,ds"
# get all specified resource types across all namespaces
alias klsa="kubectl get svc,pods,rc,deployments,ds --all-namespaces"
# get count of number of pods running per node -- requires jq - https://stedolan.github.io/jq/download/
alias knc="kubectl get pods --all-namespaces -o json | jq '.items[] | .spec.nodeName' -r | sort | uniq -c"
# map pods to nodes
alias kpn="kubectl get pods --all-namespaces -o json | jq '.items | map({podName: .metadata.name, nodeName: .spec.nodeName}) | group_by(.nodeName) | map({nodeName: .[0].nodeName, pods: map(.podName)})'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment