Clean up¶
Now that you have completed the guide, it is crucial to properly manage and remove the resources and environments you have created. This is necessary to avoid incurring unnecessary costs and potential security concerns.
Here's a step-by-step guide to help you do that.
- Clean up the cloud provider resources
- Clean up your local environment
- Clean up your repository
Warning
If you are using a new cloud account such as Google Cloud, make sure to delete the resources you created before the credits are consumed. Otherwise, you will be charged for the resources you created.
Clean up cloud provider resources¶
In this section, you will delete the resources you created on the cloud provider.
Delete the Kubernetes cluster
To delete the Google Kubernetes cluster you created, you can execute the following command:
# Delete the Kubernetes cluster
gcloud container clusters delete --zone $GCP_K8S_CLUSTER_ZONE $GCP_K8S_CLUSTER_NAME
Press Y to confirm the deletion.
To disable the Google Kubernetes Engine API, you can execute the following command:
# Disable the Google Kubernetes Engine API
gcloud services disable container.googleapis.com --force
Delete the Google Artifact Registry
To delete the Google Artifact Registry used to store the Docker images you created, you can execute the following command:
# Delete the artifact repository
gcloud artifacts repositories delete --location $GCP_CONTAINER_REGISTRY_LOCATION $GCP_CONTAINER_REGISTRY_NAME
Press Y to confirm the deletion.
To disable the Google Artifact Registry API, you can execute the following command:
# Disable the Google Artifact Registry API
gcloud services disable artifactregistry.googleapis.com --force
Delete the Google Storage bucket
Warning
If you intend to keep the Git repository but proceed with deleting the Google Storage bucket, the DVC remote will be disrupted. To continue using DVC with the Git repository, you will need to reconfigure it with a new remote.
To delete the Google Storage bucket you created, you can execute the following command:
# Delete the Google Storage bucket
gcloud storage rm --recursive gs://$GCP_BUCKET_NAME
Press Y to confirm the deletion.
Delete the Google Service Account
To delete the Google Service Account you created, you can execute the following command:
# Delete the Google Service Account
gcloud iam service-accounts delete google-service-account@${GCP_PROJECT_ID}.iam.gserviceaccount.com
Press Y to confirm the deletion.
Delete the local Google Service Account
You can run the following command to delete the Google Service Account you exported locally:
# Delete the local Google Service Account
rm ~/.config/gcloud/google-service-account-key.json
Unlink the billing account
You can run the following command to unlink the billing account from the project:
# Unlink the billing account
gcloud billing projects unlink $GCP_PROJECT_ID
Press Y to confirm the unlinking.
Delete the Google Cloud project
To delete the Google Cloud project you created, you can execute the following command:
# Delete the Google Cloud project
gcloud projects delete $GCP_PROJECT_ID
Press Y to confirm the deletion.
Close the Billing Account
To close the Billing Account you created:
- Go to the Google Cloud Billing Console.
- Select the Billing Account you created.
- Click on Account management in the menu.
- Select Actions from the project list and select Disable billing.
- Select Close Billing Account at the top of the page.
- Follow the instructions to close the account.
Remove the Payment method
To remove the payment method you added:
- Go to the Payment method in the 3-dots top right menu.
- Select the card you added and select Remove.
- Follow the instructions to remove the payment method.
Clean up your repository¶
In this section, you will delete the repository you created on GitHub.
To delete the GitHub repository you created:
- Go to the repository page in GitHub.
- Click on Settings above the repository.
- Scroll down to the "Danger Zone" section at the bottom of the page.
- Click on Delete this repository.
- Follow the instructions to delete the repository.
To delete the GitHub Personal Access Token you created:
- Go to your GitHub Settings at the top right of the page.
- Click on Developers settings in the left sidebar.
- Click on Personal access tokens in the left sidebar and then on Tokens (classic).
- Find the Personal Access Token you created for this guide.
- Click on the Delete button next to it.
- Follow the instructions to delete the token.
Clean up the BentoML model store¶
BentoML stores the models you saved during the guide in its model store at
~/bentoml. Delete it to free the disk space.
Clean up your local environment¶
In this section, you will delete the local environment you created for this guide.
Start by ensuring you have left the virtual environment created in the previous chapter.
Then, you can delete the Python virtual environment directory.
# Move back to the root directory
cd ..
# Delete the mlops-guide-notebook
rm -rf mlops-guide-notebook
# Delete the mlops-guide directory
rm -rf mlops-guide
Double-check everything¶
Before you finish, double-check that you have deleted all the resources and environments you created. This will ensure that you don't incur unexpected costs or leave any security vulnerabilities.
Here is a checklist of all the resources and environments you created.
- The cloud provider Kubernetes cluster
- The cloud provider container registry
- The cloud provider S3 bucket
- The cloud provider credentials
- The cloud provider project
- The GitHub Personal Access Tokens
- The GitHub repository
- The BentoML model store
- The project directories
- The
mlops-guide-notebookdirectory - The
mlops-guidedirectory
- The
Summary¶
By following these steps, you have successfully cleaned up the resources and environments you created during the guide. We hope you found this guide helpful and that it has given you a good understanding of the importance of cleaning up after yourself in cloud computing environments.