Skip to content

Instantly share code, notes, and snippets.

@juandspy
Created September 19, 2023 08:23
Show Gist options
  • Save juandspy/8f1fb536ff44ff62de26a36b05c97fa4 to your computer and use it in GitHub Desktop.
Save juandspy/8f1fb536ff44ff62de26a36b05c97fa4 to your computer and use it in GitHub Desktop.
Get resource quotas for your oc projects in a CSV
#/bin/bash
namespaces=$(oc get projects -o template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
echo "Namespace,Name,Type,Limits CPU,Limits Memory,PersistentVolumeClaims,Pods,Requests Storage"
for namespace in $namespaces
do
for type in "hard" "used"
do
oc get resourcequotas --namespace="$namespace" -o json | jq -r --arg type "$type" '.items[] | [.metadata.namespace, .metadata.name, $type, .status[$type]["limits.cpu"], .status[$type]["limits.memory"], .status[$type].persistentvolumeclaims, .status[$type].pods, .status[$type]["requests.storage"]] | @csv'
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment