Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Last active January 18, 2022 00:46
Show Gist options
  • Save vfarcic/a04269d359685bbd00a27643b5474ace to your computer and use it in GitHub Desktop.
Save vfarcic/a04269d359685bbd00a27643b5474ace to your computer and use it in GitHub Desktop.
####################
# Create a cluster #
####################
# Install gcloud CLI (https://cloud.google.com/sdk/docs/quickstarts) and make sure that you have GCP admin permissions
# Open https://console.cloud.google.com/cloud-resource-manager to create a new GCP project if you do not have one available already. Make sure to enable billing for that project.
PROJECT=[...] # Replace `[...]` with the name of the GCP project (e.g. jx).
echo "nexus:
enabled: false
" | tee myvalues.yaml
# The command that follows uses `-b` to run in the batch mode and it assumes that this is not the first time you create a cluster with `jx`.
# If that's not the case and this is indeed the first time you're creating a `jx` cluster, it will not have some of the default values like GitHub user and the installation might fail.
# Please remove `-b` from the command if this is NOT the first time you're creating a cluster with `jx`.
jx create cluster gke \
--cluster-name jx-rocks \
--project-id $PROJECT \
--region us-east1 \
--machine-type n1-standard-2 \
--min-num-nodes 1 \
--max-num-nodes 2 \
--default-admin-password=admin \
--default-environment-prefix tekton \
--git-provider-kind github \
--namespace cd \
--prow \
--tekton \
--batch-mode
# If asked for input, use the default answers unless you're sure you want a non-standard setup.
#######################
# Destroy the cluster #
#######################
gcloud container clusters \
delete jx-rocks \
--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
# Remove container images from GCR
IMAGE=go-demo-6
for TAG in $(gcloud container images \
list-tags gcr.io/$PROJECT/$IMAGE \
--format='get(tags)')
do
gcloud container images \
delete gcr.io/$PROJECT/$IMAGE:$TAG \
--quiet
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment