Untitled
unknown
plain_text
5 months ago
961 B
6
Indexable
kubectl get pods -n <namespace> -o json | jq ' reduce .items[] as $pod ( {cpuRequest: 0, memRequest: 0, cpuLimit: 0, memLimit: 0, excluded: []}; if ($pod.metadata.name | startswith("eric")) then if ($pod.spec.initContainers // []) == [] then .cpuRequest += ($pod.spec.containers[]?.resources.requests.cpu // "0m" | sub("m"; "") | tonumber * if test("m") then 1 else 1000 end) | .memRequest += ($pod.spec.containers[]?.resources.requests.memory // "0Mi" | sub("Mi"; "") | tonumber * if test("Gi") then 1024 else 1 end) | .cpuLimit += ($pod.spec.containers[]?.resources.limits.cpu // "0m" | sub("m"; "") | tonumber * if test("m") then 1 else 1000 end) | .memLimit += ($pod.spec.containers[]?.resources.limits.memory // "0Mi" | sub("Mi"; "") | tonumber * if test("Gi") then 1024 else 1 end) else .excluded += [$pod.metadata.name] end else .excluded += [$pod.metadata.name] end ) '
Editor is loading...
Leave a Comment