Last active
January 19, 2023 13:11
-
-
Save danifitz/8ad09001a564e0cf8266151cb8418c62 to your computer and use it in GitHub Desktop.
an inventory script to measure vcpu consumption by gcp cloudrun
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
# A sample Bash script to count the number of vCPU's consumed by GCP CloudRun. @author [email protected] | |
REGIONS=(europe-north1 us-central1) | |
for region in ${REGIONS[@]}; do | |
SERVICES=$(gcloud run services list --region $region --format="json" | jq -r '.[] | .metadata.name') | |
echo "##############################\n GCP Region: $region" | |
for service in ${SERVICES[@]}; do | |
echo "##############################\n CloudRun service: $service \n##############################\n" | |
vcpu=$(gcloud run services describe $service --region $region --format="json" | jq -r '.spec.template.spec.containers | .[].resources.limits.cpu') | |
echo "$vcpu\n" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment