Created
October 7, 2022 19:17
-
-
Save rnemeth90/498bcc5cb52cc34c17af2bd5f0fefc2d to your computer and use it in GitHub Desktop.
Kubernetes: Get Count of Pods per Node
This file contains hidden or 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
nodes=$(kubectl get nodes --no-headers | awk '{print $1}') | |
for n in ${nodes[@]}; do | |
pods=$(kubectl get pod -A --field-selector spec.nodeName=$n --no-headers | awk '{print $2}') | |
echo $n = $(echo $pods | wc -w) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice! A one-liner version: