-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhammer_script.sh
23 lines (20 loc) · 998 Bytes
/
hammer_script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
PROJECT_ID=""
LABEL_KEY="purpose"
LABEL_VALUE="see-me"
REGION="us-central1"
ZONE="us-central1-a"
# Labeling Compute Engine instances
echo "Processing Compute Engine instances..."
INSTANCE_IDS=$(gcloud compute instances list --project "$PROJECT_ID" --format="value(name)")
for INSTANCE_ID in $INSTANCE_IDS; do
echo "Updating $INSTANCE_ID with label $LABEL_KEY:$LABEL_VALUE"
gcloud compute instances update "$INSTANCE_ID" --project "$PROJECT_ID" --zone "$ZONE" --update-labels "$LABEL_KEY=$LABEL_VALUE" --quiet
done
# Labeling Kubernetes Engine clusters
echo "Processing Kubernetes Engine clusters..."
GKE_CLUSTER_IDS=$(gcloud container clusters list --project "$PROJECT_ID" --region "$REGION" --format="value(name)")
for GKE_CLUSTER_ID in $GKE_CLUSTER_IDS; do
echo "Updating $GKE_CLUSTER_ID with label $LABEL_KEY:$LABEL_VALUE"
gcloud container clusters update "$GKE_CLUSTER_ID" --project "$PROJECT_ID" --region "$REGION" --update-labels "$LABEL_KEY=$LABEL_VALUE" --quiet
done