Created
June 22, 2017 23:11
-
-
Save tcotav/75de4c358dee6af0cab077e51e409b80 to your computer and use it in GitHub Desktop.
kubectl aliases
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
# 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