Disconnect your cluster

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

Remove CAST AI resources from your 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 command to remove the resources. Terraform will destroy all remote objects managed by a particular configuration.

Clusters managed in the console

Read-only clusters

To disconnect your cluster from CAST AI:

Step 1

Click the Disconnect cluster button on the list of clusters and follow the on-screen instructions.

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

kubectl delete namespace castai-agent

Step 2

Additionally, 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.

Step 3

Remove the cluster from the console by pressing the Remove cluster button.



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

Managed service clusters

Step 1

In the console, choose the Disconnect cluster option.

Step 2

Enter the cluster name in the form and check the box to delete all nodes CAST AI created. Be aware that this might cause downtime due to reduced cluster capacity.

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

Step 3

Press the Remove cluster button to get a script that cleans up cloud resources like Roles, Bindings, and ServiceAccounts. Run the provided script in your cloud shell or terminal.

How to remove CAST AI credentials and other resources

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

Step 1

In the CAST AI console, go to the Autoscaler page and switch the toggle to OFF to disable all policies.

Step 2

Go back to the cluster list and disconnect the cluster by clicking the Disconnect cluster button and following the instructions on the screen.

Once disconnecting has finished and the cluster status has changed to Disconnected, move on to the next step.

Step 3

Click the Remove cluster button and execute the provided offboarding script in your cloud shell or terminal 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

By following these steps, you can successfully disconnect your cluster from CAST AI and remove all associated resources.