Skip to content

Instantly share code, notes, and snippets.

@omerh
Last active May 7, 2020 10:43
Show Gist options
  • Save omerh/4578cadba4a2548d7ed7b7d86e673d9b to your computer and use it in GitHub Desktop.
Save omerh/4578cadba4a2548d7ed7b7d86e673d9b to your computer and use it in GitHub Desktop.
#!/bin/bash
nodes=$(kubectl get nodes --no-headers |awk '{print $1}')
for n in $nodes; do
pods=$(kubectl describe node $n | grep -A100 Namespace | grep -B100 'Allocated resources' | tail -n +3 | grep -v 'Allocated' | grep -v 'monitoring\|logging\|kube-' | wc -l)
if [[ $pods -lt 1 ]]; then
echo "Node $n has $pods running"
#else
# echo "Node $n has $pods running"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment