Delete Instance
This feature is used to delete MySQL-PXC instances. Users can delete a specified instance by specifying the instance name and namespace. After deleting the instance, you can choose whether to retain the instance data. If the instance data is not retained, it will be permanently deleted and cannot be recovered.
Procedure
- Determine whether to retain data
kubectl patch mysql -n <namespace> <name> --type json -p '[{"op": "add", "path": "/metadata/finalizers/-", "value": "delete-pvc"}]'
current_finalizers=$(kubectl get mysql -n <namespace> <name> -o jsonpath='{.metadata.finalizers}' | jq --arg f "delete-pvc" 'map(select(. != $f))')
kubectl patch mysql -n <namespace> <name> --type merge -p "{\"metadata\":{\"finalizers\":$current_finalizers}}"
- Delete the instance
kubectl delete mysql -n <namespace> <name>