Skip to content

Instantly share code, notes, and snippets.

@rms1000watt
Last active November 9, 2020 19:24
Show Gist options
  • Save rms1000watt/5813ce7a4b1516d917e2b90d847c3077 to your computer and use it in GitHub Desktop.
Save rms1000watt/5813ce7a4b1516d917e2b90d847c3077 to your computer and use it in GitHub Desktop.
k8s cluster memory % for 16GB RAM VMs
VM_MEM=16
VM_NODES=$(kubectl top node --sort-by memory | grep -iv memory | wc -l)
K8S_MEM=$(kubectl top node --sort-by memory | awk '{print $5}' | tr -d '%' | grep -iv memory | paste -s -d+ - | bc)
echo "Cluster Memory: $(($VM_NODES*$VM_MEM*100/$K8S_MEM))%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment