Skip to content

Latest commit

 

History

History
59 lines (39 loc) · 1.77 KB

destroy-a-tidb-cluster.md

File metadata and controls

59 lines (39 loc) · 1.77 KB
title summary aliases
Destroy TiDB Clusters in Kubernetes
Learn how to delete TiDB Cluster in Kubernetes.
/docs/tidb-in-kubernetes/dev/destroy-a-tidb-cluster/

Destroy TiDB Clusters in Kubernetes

This document describes how to deploy TiDB clusters in Kubernetes.

Destroy a TiDB cluster managed by TidbCluster

To destroy a TiDB cluster managed by TidbCluster, run the following command:

{{< copyable "shell-regular" >}}

kubectl delete tc ${cluster_name} -n ${namespace}

If you deploy the monitor in the cluster using TidbMonitor, run the following command to delete the monitor component:

{{< copyable "shell-regular" >}}

kubectl delete tidbmonitor ${tidb_monitor_name} -n ${namespace}

Destroy a TiDB cluster managed by Helm

To destroy a TiDB cluster managed by Helm, run the following command:

{{< copyable "shell-regular" >}}

helm delete ${cluster_name} --purge

Delete data

The above commands that destroy the cluster only remove the running Pod, but the data is still retained. If you want to delete the data as well, use the following commands:

Warning:

The following commands delete your data completely. Please be cautious.

To ensure data safety, do not delete PVs on any circumstances, unless you are familiar with the working principles of PVs.

{{< copyable "shell-regular" >}}

kubectl delete pvc -n ${namespace} -l app.kubernetes.io/instance=${cluster_name},app.kubernetes.io/managed-by=tidb-operator

{{< copyable "shell-regular" >}}

kubectl get pv -l app.kubernetes.io/namespace=${namespace},app.kubernetes.io/managed-by=tidb-operator,app.kubernetes.io/instance=${cluster_name} -o name | xargs -I {} kubectl patch {} -p '{"spec":{"persistentVolumeReclaimPolicy":"Delete"}}'