skills/kubeblocks-delete-cluster/SKILL.md
Safely delete a KubeBlocks database cluster with pre-deletion checks for backups, PVCs, and dependent resources. Use when the user wants to remove, delete, destroy, tear down, or clean up a database cluster. NOT for stopping a cluster temporarily (see kubeblocks-cluster-lifecycle) or uninstalling the KubeBlocks operator (see kubeblocks-install skill).
npx skillsauth add apecloud/kubeblocks-skills kubeblocks-delete-clusterInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Safely remove a KubeBlocks-managed database cluster. This skill covers pre-deletion checks, handling the terminationPolicy, and cleaning up residual resources.
Official docs: https://kubeblocks.io/docs/preview/user_docs/kubeblocks-for-mysql/cluster-management/delete-mysql-cluster Full doc index: https://kubeblocks.io/llms-full.txt
- [ ] Step 1: Pre-deletion checklist
- [ ] Step 2: Handle terminationPolicy
- [ ] Step 3: Delete the cluster
- [ ] Step 4: Verify deletion
- [ ] Step 5: Clean up residual resources (optional)
Before deleting, confirm the following with the user:
kubectl get cluster -n <namespace>
kubectl get cluster <cluster-name> -n <namespace> -o jsonpath='{.spec.terminationPolicy}'
| Policy | What Happens on Delete |
|--------|----------------------|
| DoNotTerminate | Deletion is blocked. Must patch before deleting. |
| Delete | Deletes pods and PVCs. Retains backups. |
| WipeOut | Deletes everything including backups. |
kubectl get backup -n <namespace> -l app.kubernetes.io/instance=<cluster-name>
If backups exist and the policy is WipeOut, warn the user that all backups will also be deleted.
kubectl get opsrequest -n <namespace> -l app.kubernetes.io/instance=<cluster-name>
Cancel any running OpsRequests before deleting:
kubectl delete opsrequest <ops-name> -n <namespace>
If the current policy is DoNotTerminate, the cluster cannot be deleted until it is changed. Patch it:
kubectl patch cluster <cluster-name> -n <namespace> \
--type merge -p '{"spec":{"terminationPolicy":"Delete"}}'
Warning: Confirm with the user before changing from
DoNotTerminate. This policy exists to protect production clusters from accidental deletion.
To also delete backups, use WipeOut instead of Delete.
kubectl delete cluster <cluster-name> -n <namespace>
This may take a minute as KubeBlocks gracefully shuts down database instances and cleans up resources.
Confirm the cluster is gone:
kubectl get cluster <cluster-name> -n <namespace>
Expected output:
Error from server (NotFound): clusters.apps.kubeblocks.io "<cluster-name>" not found
Confirm pods are terminated:
kubectl get pods -n <namespace> -l app.kubernetes.io/instance=<cluster-name>
Expected: no resources found.
If the terminationPolicy was DoNotTerminate (before patching) or if PVCs remain for any reason:
kubectl get pvc -n <namespace> -l app.kubernetes.io/instance=<cluster-name>
To delete them:
kubectl delete pvc -n <namespace> -l app.kubernetes.io/instance=<cluster-name>
Caution: Deleting PVCs permanently destroys data. Make sure backups exist if the data might be needed.
Connection credential secrets may remain:
kubectl get secret -n <namespace> | grep <cluster-name>
To delete them:
kubectl delete secret -n <namespace> -l app.kubernetes.io/instance=<cluster-name>
kubectl get configmap -n <namespace> -l app.kubernetes.io/instance=<cluster-name>
To delete them:
kubectl delete configmap -n <namespace> -l app.kubernetes.io/instance=<cluster-name>
Cluster deletion hangs (stuck in Deleting):
kubectl get cluster <cluster-name> -n <namespace> -o jsonpath='{.metadata.finalizers}'kubectl logs -n kb-system -l app.kubernetes.io/name=kubeblocks --tail=50terminationPolicy is DoNotTerminate and user forgot the policy:
kubectl delete command will return an error. Patch the policy first (Step 2).PVCs remain after deletion:
terminationPolicy was DoNotTerminate. Clean them up in Step 5.For general agent safety conventions (dry-run, status confirmation, production protection), see safety-patterns.md.
devops
Expand persistent volume storage for KubeBlocks database clusters via OpsRequest. Requires the StorageClass to support volume expansion (allowVolumeExpansion=true). Use when the user needs more disk space, wants to increase storage, expand volumes, or resize PVCs. NOT for changing CPU/memory (see vertical-scaling) or adding more replicas (see horizontal-scaling). Note that volume shrinking is not supported by Kubernetes.
data-ai
Scale CPU and memory resources for KubeBlocks database clusters via OpsRequest (vertical scaling). Supports in-place updates when the feature gate is enabled. Use when the user wants to change, increase, decrease, resize, or adjust CPU or memory resources of a database cluster. NOT for adding/removing replicas or shards (see horizontal-scaling) or expanding disk storage (see volume-expansion).
data-ai
Upgrade the KubeBlocks operator itself via Helm. Covers update operator, upgrade to v1.0, update kubeblocks version, and CRD updates. Use when the user wants to upgrade KubeBlocks, update the operator, or upgrade to a new KubeBlocks release. NOT for upgrading database engine versions (see minor-version-upgrade).
development
Diagnostic guide for KubeBlocks-managed database clusters. Use when the user reports troubleshoot, debug, diagnose, not working, error, failed, stuck, CrashLoopBackOff, cluster exception, or similar problems with their database cluster. This skill guides the agent through diagnostic steps — it does NOT perform actions.