Created
July 18, 2023 12:16
-
-
Save petskratt/f4009f2bf1a1ebcbb96196cae5ed3be5 to your computer and use it in GitHub Desktop.
Revisions
-
petskratt created this gist
Jul 18, 2023 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ # Display current K8S resource usage for a namespace (either first argument or current) # Add to your ~/.profile, copy-paste results for analysis to https://docs.google.com/spreadsheets/d/1v___k9gYo4RI4wWIluJcdqOVHCFEccLQMOCGxvrZGtk/edit?usp=sharing # [email protected] / 2023-07-18 function resource_capacity() { if [ -z "$1" ] then namespace=$(kubectl config view --minify -o jsonpath='{..namespace}') else namespace="$1" fi kubectl resource-capacity --util --pods -n $namespace | tr -s '[:blank:]' "\t" | sed -r 's/([[:digit:]]+)Mi\t/\1\t/g' | sed -r 's/([[:digit:]]+)m\t/\1\t/g' | sed -r 's/^(gke-k[[:digit:]]+)-gcp-/\1\t/g' | grep -v "*" | sed '/^\t$/d' | grep -v "POD\tCPU\tREQUESTS" | sed -r 's/\([[:digit:]]+%\)(\t|$)//g' | cut -f3- }