Last active
February 8, 2018 16:40
-
-
Save george-angel/c95b21262934da53df6481f6264866bc to your computer and use it in GitHub Desktop.
Kubernetes resources per namespace
This file contains 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
#!/bin/bash | |
## usage: ./rs-ns <kube-context> | sort -h -k 2 -r | |
export env=${1} | |
total() { | |
ns=${1} | |
echo "${ns} $(kubectl --context=${env} -n${ns} top pod | tail -n +2 | awk '{print $3}' | cut -d'M' -f1 | paste -s -d+ - | bc) " | |
} | |
export -f total | |
kubectl --context=${env} get ns | tail -n +2 | awk '{print $1}' | xargs -I {} -n1 sh -c 'total {}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment