kubectl get resourcequota -A -o json | jq -r '
["NAMESPACE", "USED_CPU", "HARD_CPU", "REQUEST_RATIO(%)"],
["---------", "--------", "--------", "----------------"],
(.items[] |
select(.status.hard["requests.cpu"] != null) |
# 코어 단위(m)로 정규화 함수 적용
def to_m: (if endswith("m") then rtrimstr("m") | tonumber else tonumber * 1000 end);
(.status.used["requests.cpu"] // "0") as $used_str |
.status.hard["requests.cpu"] as $hard_str |
($used_str | to_m) as $used |
($hard_str | to_m) as $hard |
[
.metadata.namespace,
$used_str,
$hard_str,
(if $hard > 0 then (($used / $hard * 100 * 100 | round) / 100 | tostring + "%") else "N/A" end)
]
) | @tsv' | column -t