Skip to content

Commit

Permalink
chore(toil improvement): add script to find demo clusters for obscure…
Browse files Browse the repository at this point in the history
…ly named VMs (#1412)
  • Loading branch information
tommartensen authored Nov 29, 2024
1 parent f007895 commit 606d967
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions scripts/orphan-clusters/find-demo-clusters-for-vms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# This script finds infra cluster names for obscure VM prefixes from the Janitor control output
# gcloud compute instances list --project acs-team-temp-dev --format json | jq -r '.[].name' | sed 's/gke-//; s/-default-pool.*//; s/-master.*//; s/-worker.*//' | sort | uniq

set -euo pipefail

if [[ "$#" -lt "1" ]]; then
>&2 echo "Usage: find-demo-clusters-for-vms.sh <VM prefix>"
exit 6
fi

CLUSTER="$1"
INSTANCE=$(gcloud compute instances list --project acs-team-temp-dev --format json \
| jq -r '.[].name' \
| grep "^gke-${CLUSTER}.*" \
| head -n 1)

gcloud compute instances describe "${INSTANCE}" --project acs-team-temp-dev --format json | jq -r '.labels.name'

0 comments on commit 606d967

Please sign in to comment.