Skip to content

Instantly share code, notes, and snippets.

@rjchicago
Created September 30, 2024 14:20
Show Gist options
  • Select an option

  • Save rjchicago/7c9f7fe1eeb4e7456431a2d1c1b7c9c6 to your computer and use it in GitHub Desktop.

Select an option

Save rjchicago/7c9f7fe1eeb4e7456431a2d1c1b7c9c6 to your computer and use it in GitHub Desktop.
# Include all kube configs
export KUBECONFIG=~/.kube/config$(for YAML in $(find ${HOME}/.kube -name '*.y*ml') ; do echo -n ":${YAML}"; done)
# get pods per namespace
alias kpns="kubectl get pods -A | sed 1d | awk '{print \$1}' | sort | uniq -c | sort -k1 -n -r"
# get pods per node
alias kpn="kubectl get pods -A -o jsonpath='{range .items[?(@.spec.nodeName)]}{.spec.nodeName}{\"\n\"}{end}' | sort | uniq -c | sort -rn"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment