Pause and delete
Pause a non-production cluster
Section titled “Pause a non-production cluster”To save money on a cluster you don’t use for a while, scale its node pools to zero and stop its Cloud SQL instance. The WAL disks, the bucket and the metadata are kept, so the cluster comes back as it was.
While paused, clients can’t publish or consume, and the console shows the cluster as offline. The cluster management fee, the regional disks, the bucket and the internal load balancer keep billing.
PROJECT=acme-lowtide-dev REGION=us-central1 CLUSTER=lowtide-orders-dev
# Node pools: autoscaling off first, or it adds nodes back for the pending pods.for pool in $(gcloud container node-pools list --cluster $CLUSTER --region $REGION --project $PROJECT --format='value(name)'); do gcloud container node-pools update $pool --cluster $CLUSTER --region $REGION --project $PROJECT --no-enable-autoscaling gcloud container clusters resize $CLUSTER --node-pool $pool --num-nodes 0 --region $REGION --project $PROJECT --quietdone
# A scale-up the autoscaler started before it was turned off can land after the# resize. Check that no node group is left above 0; if one is, run the resize again.gcloud compute instance-groups managed list --project $PROJECT \ --filter="name~^gke-$CLUSTER- AND targetSize>0" --format='value(name)'
# Cloud SQLSQL=$(gcloud sql instances list --project $PROJECT --format='value(name)' --filter="name~^$CLUSTER-")gcloud sql instances patch $SQL --project $PROJECT --activation-policy NEVERResume
Section titled “Resume”gcloud sql instances patch $SQL --project $PROJECT --activation-policy ALWAYS
for pool in $(gcloud container node-pools list --cluster $CLUSTER --region $REGION --project $PROJECT --format='value(name)'); do gcloud container node-pools update $pool --cluster $CLUSTER --region $REGION --project $PROJECT \ --enable-autoscaling --min-nodes 1 --max-nodes 2 gcloud container clusters resize $CLUSTER --node-pool $pool --num-nodes 1 --region $REGION --project $PROJECT --quietdoneUse the node counts your size needs (--max-nodes is twice the gateway pods per zone for the gateway pool). The pods are ready again after about 10 minutes: nodes start, the disks attach and each pod recovers its WAL. The next terraform apply of the module also restores the node pools.
Delete a cluster lowtide set up
Section titled “Delete a cluster lowtide set up”On the cluster page, select Delete cluster and type the cluster’s name. The provisioner needs its access for this, so grant it again first if you removed it.
The deletion run:
- turns deletion protection off on what exists,
- records the WAL disks,
- empties the segment bucket,
- destroys everything the setup created: the GKE cluster, the Cloud SQL instance with the metadata, the bucket, the network and the service accounts,
- deletes the WAL disks, if you left Also delete the disks the cluster keeps on,
- deletes the Terraform state bucket last,
- removes the cluster from the console.
Clients of the endpoint stop working, and the messages in the cluster are gone. This can’t be undone.
If you turned off Also delete the disks the cluster keeps, the run page lists the disks and the commands to delete them later. They bill until you do.
Afterwards, remove the provisioner’s remaining grants with the commands on the Setup tab, and delete the shadow role you created in each Pub/Sub project if no other cluster uses it.
Remove from the console only removes the cluster from lowtide Cloud and leaves everything in your project. Use it if you deleted the resources yourself.
Delete a cluster you installed with Terraform
Section titled “Delete a cluster you installed with Terraform”-
Set
deletion_protection = falseand runterraform apply. GKE and Cloud SQL refuse deletion otherwise. -
List the WAL disks before you destroy, so you can find them afterwards:
Terminal window gcloud compute disks list --project PROJECT \--filter="description~'\"kubernetes.io/created-for/pvc/namespace\":\"lowtide\"'" -
Empty the segment bucket, or the destroy fails:
gcloud storage rm -r "gs://BUCKET/**". -
Run
terraform destroy. The Helm release is uninstalled first. -
Delete the WAL disks once you are sure nothing on them is needed. They are kept on purpose, because a WAL can hold acknowledged messages that are not in Cloud Storage yet. They bill until you delete them:
Terminal window gcloud compute disks delete DISK --region REGION --project PROJECT -
Remove the cluster in the console (Delete cluster).
Left behind on purpose: the Private Service Access peering (free; Cloud SQL takes a while to release it), the enabled APIs, and the shadows in your Pub/Sub projects. The Cloud SQL instance name stays reserved for about a week. The module adds a random suffix, so a new install doesn’t collide with it.
Delete a Helm installation
Section titled “Delete a Helm installation”helm uninstall lowtide -n lowtide removes the workloads. The WAL volumes are kept (Retain). Delete them, your bucket, database and service accounts yourself, then remove the cluster in the console.