Is there a way to get the memory consumption per namespace on Kubernetes?
No need for a ResourceQuota
to get this metric. However it is not provided by an ad-hoc kubectl
command. We need to compute the sum ourselves.
Here is a one-liner to get total CPU & RAM usage for a given namespace:
kubectl top pods -n <namespace> | awk 'BEGIN {mem=0; cpu=0} {mem += int($3); cpu += int($2);} END {print "Mem
ory: " mem "Mi" "\n" "Cpu: " cpu "m"}'
Example output:
Memory: 717Mi
Cpu: 257m
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With