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 Kubernetes Cluster API controllers (a management cluster). 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 management 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

    or:

    ocne cluster delete --config myconfig.yaml

    The management cluster deletes the OCI workload cluster. If the cluster is self managed, an ephemeral cluster is created and the Kubernetes Cluster API resources are migrated to the ephemeral cluster.

    Tip:

    Monitor the cluster deletion process in a separate terminal session. Set the KUBECONFIG environment variable to the management cluster.

    export KUBECONFIG=$(ocne cluster show --cluster-name cluster-name)

    Replace cluster_name with the name of the management cluster. Then enter:

    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 management cluster.

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

    ocne cluster delete --cluster-name mycluster
  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.