Delete a Cluster

Learn how to delete a Kubernetes cluster on OCI.

Deleting a self-managed cluster requires that a second cluster is available to run the controllers. This is because the final stages of cluster destruction terminates any remaining compute instances, and, by extension, cluster nodes. When this is complete, no compute instances are available to run the controllers. If a second cluster isn't available, an ephemeral cluster is created to service this need.

Deleting an OCI Cluster

Delete a Kubernetes cluster on OCI.

  1. Delete the Kubernetes cluster running on OCI.

    Use the ocne cluster delete command to delete the cluster. They syntax to use is:

    ocne cluster delete 
    [{-C|--cluster-name} name]
    [{-c|--config} URI] 
    [{-P|--provider} provider]
    [{-s|--session} URI]

    For more information on the syntax options, see Oracle Cloud Native Environment: CLI.

    For example:

    ocne cluster delete --cluster-name mycluster

    If the cluster is self managed, an ephemeral cluster is created and the Kubernetes Cluster API resources are migrated to the ephemeral cluster. If the cluster isn't self managed, the ephemeral cluster already contains the Kubernetes Cluster API resources. The ephemeral cluster deletes the OCI cluster.

    Tip:

    Monitor the cluster deletion process in a separate terminal session by setting the KUBECONFIG environment variable to the ephemeral cluster and listing the clusters. For example:

    setenv KUBECONFIG=$HOME/.kube/kubeconfig.ocne-ephemeral.local
    kubectl get cluster -A

    The cluster object is in the deleting state. When the cluster object is no longer available, the delete is completed.

  2. Delete the ephemeral cluster.

    You might also need to delete the ephemeral cluster, depending on the settings in the environment. Use the ocne cluster delete command to delete the ephemeral cluster. For example:

    ocne cluster delete --cluster-name ocne-ephemeral
  3. Delete Oracle Cloud Infrastructure resources.

    You might need to manually remove some Oracle Cloud Infrastructure resources. While the compute instances, Virtual Cloud Networks, and Network load balancers in the cluster are terminated, any OCK images in the Objects Storage bucket, and custom compute images aren't removed. If you don't want to retain those objects, sign in to the Oracle Cloud Infrastructure console and remove them manually.