Skip to content

Instantly share code, notes, and snippets.

@garystafford
Last active January 20, 2019 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garystafford/50c6644590e8befb82a5bdff146c7fc6 to your computer and use it in GitHub Desktop.
Save garystafford/50c6644590e8befb82a5bdff146c7fc6 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# author: Gary A. Stafford
# site: https://programmaticponderings.com
# license: MIT License
# purpose: Tear down GKE cluster and associated resources
# Constants - CHANGE ME!
readonly PROJECT='gke-confluent-atlas'
readonly CLUSTER='storefront-api'
readonly REGION='us-central1'
readonly ZONE='us-central1-a'
# Delete GKE cluster (time in foreground)
time yes | gcloud beta container clusters delete $CLUSTER --zone $ZONE
# Confirm network resources are also deleted
gcloud compute forwarding-rules list
gcloud compute target-pools list
gcloud compute firewall-rules list
# In case target-pool associated with Cluster is not deleted
yes | gcloud compute target-pools delete \
$(gcloud compute target-pools list \
--filter="region:($REGION)" --project $PROJECT \
| awk 'NR==2 {print $1}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment