Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Created October 3, 2019 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vfarcic/1b7a1c833bae1d5da02f4fd7b3cd3c17 to your computer and use it in GitHub Desktop.
Save vfarcic/1b7a1c833bae1d5da02f4fd7b3cd3c17 to your computer and use it in GitHub Desktop.
####################
# Create a cluster #
####################
PROJECT=[...] # Replace `[...]` with the name of the GCP project (e.g. jx).
CLUSTER_NAME=[...] # Replace `[...]` with the name of the cluster (e.g., jx-boot)
gcloud auth login
gcloud container clusters \
create $CLUSTER_NAME \
--project $PROJECT \
--region us-east1 \
--machine-type n1-standard-2 \
--enable-autoscaling \
--num-nodes 1 \
--max-nodes 2 \
--min-nodes 1
kubectl create clusterrolebinding \
cluster-admin-binding \
--clusterrole cluster-admin \
--user $(gcloud config get-value account)
#######################
# Destroy the cluster #
#######################
gcloud container clusters \
delete $CLUSTER_NAME \
--region us-east1 \
--quiet
# Remove unused disks to avoid reaching the quota (and save a bit of money)
gcloud compute disks delete \
--zone us-east1-b \
$(gcloud compute disks list \
--filter="zone:us-east1-b AND -users:*" \
--format="value(id)") --quiet
gcloud compute disks delete \
--zone us-east1-c \
$(gcloud compute disks list \
--filter="zone:us-east1-c AND -users:*" \
--format="value(id)") --quiet
gcloud compute disks delete \
--zone us-east1-d \
$(gcloud compute disks list \
--filter="zone:us-east1-d AND -users:*" \
--format="value(id)") --quiet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment