1.2.3.2.6 删除 TiDB 集群

本小节演示删除名为 “test” 的 TiDB 集群。

1. 通过 helm 删除 TiDB Cluster

  1. # helm list
  2. NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
  3. test 1 Sat Mar 7 22:30:16 2020 DEPLOYED tidb-cluster-v1.0.6 dba-test
  4. tidb-operator 1 Sat Mar 7 05:02:15 2020 DEPLOYED tidb-operator-v1.0.6 tidb-admin
  5. # helm delete test --purge
  6. release "test" deleted

请注意: 删除操作非常危险,请删除指定 TiDB 集群 ,千万不要误删除。

2. 删除 PVC

  1. # kubectl delete pvc -n dba-test -l app.kubernetes.io/instance=test,app.kubernetes.io/managed-by=tidb-operator
  2. persistentvolumeclaim "pd-test-pd-0" deleted
  3. persistentvolumeclaim "pd-test-pd-1" deleted
  4. persistentvolumeclaim "pd-test-pd-2" deleted
  5. persistentvolumeclaim "pd-test-pd-3" deleted
  6. persistentvolumeclaim "tikv-test-tikv-0" deleted
  7. persistentvolumeclaim "tikv-test-tikv-1" deleted
  8. persistentvolumeclaim "tikv-test-tikv-2" deleted

请注意: 删除操作非常危险,请删除指定 TiDB 集群的 PVC ,千万不要误删除。

3. 删除 PV

  1. # kubectl get pv -l app.kubernetes.io/namespace=dba-test,app.kubernetes.io/managed-by=tidb-operator,app.kubernetes.io/instance=test -o name|xargs -I {} kubectl patch {} -p '{"spec":{"persistentVolumeReclaimPolicy":"Delete"}}'
  2. persistentvolume/local-pv-2c956bbd patched
  3. persistentvolume/local-pv-3a4dae53 patched
  4. persistentvolume/local-pv-3c7e9ebb patched
  5. persistentvolume/local-pv-5ebe9899 patched
  6. persistentvolume/local-pv-682d37c9 patched
  7. persistentvolume/local-pv-af00e20c patched
  8. persistentvolume/local-pv-d4cf548e patched

一分钟之后,检查 PV 状态:

  1. # kubectl get pv
  2. NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
  3. local-pv-2c956bbd 1468Mi RWO Delete Available local-storage 64s
  4. local-pv-3a4dae53 1468Mi RWO Delete Available local-storage 72s
  5. local-pv-3c7e9ebb 1468Mi RWO Delete Available local-storage 54s
  6. local-pv-5cb252d7 1974Mi RWO Delete Available local-storage 24h
  7. local-pv-5ebe9899 1468Mi RWO Delete Available local-storage 58s
  8. local-pv-682d37c9 1468Mi RWO Delete Available local-storage 72s
  9. local-pv-af00e20c 1974Mi RWO Delete Available local-storage 24h
  10. local-pv-d4cf548e 1468Mi RWO Delete Available local-storage 58s
  11. local-pv-eb0e3c9f 1974Mi RWO Delete Available local-storage 24h

PV 资源已全部释放。至此,“test” TiDB 集群已经删除完毕。