Skip to content

Destroy your Nebari deployment

Updated 4 min read

This is a guide on how to destroy your Nebari cluster, this includes all resources created the first time you deployed it. With your nebari-config.yaml configuration file, you can use a handy destroy command to automatically destroy resources with Nebari.

You will need to export your cloud credentials, as you would for a nebari deploy, before you can destroy these cloud resources.

You can specify the nebari-config.yaml configuration file created while deploying Nebari to destroy the resources as well. Type the following command on your command line:

Terminal window
nebari destroy -h
Terminal window
Usage: nebari destroy [OPTIONS]
Destroy the Nebari cluster from your nebari-config.yaml file.
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
* --config -c TEXT qhub configuration file path [default: None] [required] │
--output -o TEXT output directory [default: ./]
--disable-render Disable auto-rendering before destroy
--disable-prompt Destroy entire Nebari cluster without confirmation request. Suggested for CI use.
--help -h Show this message and exit.
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Once you've decided to destroy your cluster and have read through the nebari destroy --help command, you are you now ready.

Terminal window
nebari destroy -c nebari-config.yaml

The terminal will prompt you to press enter to verify that you wish to destroy your Nebari cluster.

If the destruction is successful, you will see the following output:

Terminal window
[terraform]: Nebari properly destroyed all resources without error

Congratulations! You have successfully destroyed your Nebari deployment and the associated resources!

Here, we outline how to find and destroy resources from the AWS console.

  1. Sign in to your AWS account and in the search bar type Tag Editor
Search for Tag Editor in the AWS console
  1. From the Resource Groups & Tag Editor page, navigate to Tag Editor from the left most panel
Navigate to the Tag Editor in the AWS console
  1. Fill out the form as follows:
    • Regions - the region you deployed your Nebari cluster (or select all regions)
    • Resource types - select All supported resource types
    • Tags
      • select Environment for key (on the left)
      • enter the namespace you chose for your Nebari cluster (on the right)
Use the Tag Editor to filter for lingering Nebari resources
  1. From here you can filter further if needed by entering the name of your Nebari cluster.

  2. At this point, select the resource you wish to destroy. This will open another tab for you to destroy that resource.

Destroy AWS resources using a dev tool script

Section titled “Destroy AWS resources using a dev tool script”

This method of destroying lingering AWS resources requires cloning down the Nebari repo.

Terminal window
git clone https://github.com/Quansight/qhub.git

Once cloned, you can run a script which will attempt to destroy all lingering AWS resources.

Terminal window
python /path/to/qhub/scripts/aws-force-destroy.py -c /path/to/nebari-config.yaml

This will print to the terminal the resources it has destroyed. This scripts often needs to be run multiple times before all the resources are fully destroyed.

If you deployed your Nebari cluster on Azure and the nebari destroy command failed, you will need to destroy one resource: the resource group.

You will need Azure's CLI az installed and configured. Then run the following.

Terminal window
az group delete --resource-group "<project-name>-<namespace>"

Or if you'd prefer, you can destroy the resource group from the Azure portal, follow these instructions.

If you deployed your Nebari cluster on GCP and the nebari destroy command failed, you will need to destroy two resources, the Kubernetes cluster (GKE) and cloud storage bucket (GCS).

You will need Google's gcloud and gsutil.

To destroy the cloud storage bucket, run the following.

Terminal window
gsutil -m rm -r gs://<project-name>-<namespace>-terraform-state

And to destroy the Kubernetes cluster, run the following.

Terminal window
gcloud container clusters delete <project-name>-<namespace> --region <region>

If you wish to destroy the cloud storage bucket from the GCP console, follow these instructions on Deleting buckets. And to destroy the Kubernetes cluster from the GCP console, follow these instructions on Deleting a cluster.