Last active
June 8, 2017 17:56
-
-
Save jeremywadsack/2a006c272ae9bcef175fe1758391e4a0 to your computer and use it in GitHub Desktop.
K8s resource requests by node
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
# Kuberentes doesn't provide information about resource resquest in the `get` command, even in JSON mode | |
# This is the best I've got for getting a report of the total resource request allocation per node | |
kubectl describe nodes | egrep -A 4 '^Name:|^Allocated resources' | egrep '^Name:|Requests|%)' |
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
#!/usr/bin/env bash | |
# Kuberentes doesn't provide information about resource resquest in the `get` command, even in JSON mode | |
# This awkness provides a CSV of resource allocation and limits for the entire cluster | |
kubectl describe nodes | awk ' | |
BEGIN { | |
name="" | |
OFS="," | |
print "Node,Namespace,Pod Name,CPU Request,CPU Request Percent,CPU Limit,CPU Limit Percent,Memory Request,Memory Request Percent,Memory Limit,Memory Limit Percent" | |
} | |
{ | |
if ( $1 == "Name:" ) name = $2 | |
if ( $4 ~ /^\([0-9]+%\)$/ && $2 !~ /^\([0-9]+%\)$/ ) print name,$1,$2,$3,substr($4,2,length($4)-2),$5,substr($6,2,length($6)-2),$7,substr($8,2,length($8)-2),$9,substr($10,2,length($10)-2) | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment