Disconnect your cluster

Learn how to disconnect your cluster from CAST AI and remove all related data.

Remove CAST resources from a cluster

Depending on how you used and managed CAST in a cluster, you can remove it in two distinct ways.

Terraform-managed clusters

Run the [terraform destroy](https://developer.hashicorp.com/terraform/cli/commands/destroy) command to remove the resources. Terraform will destroy all remote objects managed by a particular configuration.

Clusters managed in the console

1. Read-only clusters

If you want to disconnect your cluster from CAST AI, click the Disconnect cluster button on the list of clusters and follow instructions on the screen.

Alternatively, run the following command in your terminal to access the cluster:

kubectl delete namespace castai-agent

Apart from that, delete the following Kubernetes objects related to the CAST AI agent:

clusterrole.rbac.authorization.k8s.io/castai-agent created  
clusterrolebinding.rbac.authorization.k8s.io/castai-agent created

Once the cluster is disconnected, its status will update to Disconnected. You can remove it from the console by pressing the Delete cluster button.

The cluster will continue to run as normal as deleting the cluster in CAST AI only removes it from the console.

2. Managed service clusters

In the console, choose the Disconnect cluster option.

Enter the cluster name in the form and tick the checkbox to delete all the nodes CAST AI created. Please note that this might cause downtime due to reduced cluster capacity.

When the cluster disconnects from the Cast AI, it changes its status label from Disconnecting to Disconnected.

Press the Remove cluster button, and you will get a script to clean up cloud resources, like Roles, Bindings, and ServiceAccounts.

How to remove CAST AI credentials and other resources

Follow these steps to ensure that you remove CAST AI from your cluster altogether:

  1. In the CAST AI console, go to the Autoscaler page and click the Disable all policies option.
  2. Disconnect the cluster by clicking the Disconnect cluster button and follow instructions on the screen.
  3. Execute the provided offboarding script to remove CAST AI-created resources from your cloud account.

Potential spot webhook leftovers

To check for CAST AI spot webhook configuration leftovers in the cluster, run the following in your terminal:

kubectl get mutatingwebhookconfigurations

If you find castai-pod-node-lifecycle on the list, delete it by running the following:

kubectl delete mutatingwebhookconfigurations castai-pod-node-lifecycle