Skip to content

Instantly share code, notes, and snippets.

@ruzickap
Created August 28, 2020 13:13
Show Gist options
  • Save ruzickap/38371f3a7d590907870dfe314ad9bb60 to your computer and use it in GitHub Desktop.
Save ruzickap/38371f3a7d590907870dfe314ad9bb60 to your computer and use it in GitHub Desktop.
Show number of containers running on all the worker nodes in Kubernetes
GET_NODES=$(kubectl get node -o=custom-columns='NAME:metadata.name' | grep -v ^NAME)
for NODE in ${GET_NODES}; do
echo -en "${NODE}:\t"
kubectl get po --field-selector=status.phase=Running --all-namespaces -o json | jq -r ".items[] | select(.spec.nodeName==\"${NODE}\") | .metadata.name" | wc -l
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment