Delete PersistentVolumes in Kubernetes
Deleting a PersistentVolume (PV) can be necessary for a variety of reasons, such as removing a broker and its data from the cluster or performing maintenance or upgrades on the PersistentVolume.
A running Redpanda deployment on a Kubernetes cluster.
PersistentVolumes for either the Redpanda data directory or the Tiered Storage cache.
To delete a PersistentVolume, follow these steps to ensure that your data is moved to other brokers in the cluster.
Identify the PV that you want to delete:
kubectl get persistentvolume
Decommission the broker that has a PersistentVolumeClaim (PVC) bound to the PV. Decommissioning ensures no data loss by gracefully moving the broker’s topic partitions and replicas to other brokers in the cluster. See Decommission Brokers.
Delete the PVC that is bound to your PV:
kubectl delete persistentvolumeclaim <pvc-name> -n redpanda
reclaimPolicyof your PV is not
Delete, delete the PV:
kubectl delete persistentvolume <pv-name>
Delete the Pod whose PVC was bound to the deleted PV:
The StatefulSet schedules a new Pod on the same worker node and assigns it a unique node ID.
If you use PVs for the Tiered Storage cache, the Pod will have a new PVC bound to a PV that is set in
storage.tieredStoragePersistentVolume.storageClass. See Tiered Storage Caching.
Verify that the new Redpanda broker is running and that it has access to the appropriate PersistentVolume.
kubectl -n redpanda exec -ti redpanda-0 -c redpanda -- \ rpk cluster info \ --brokers <broker-url>:<kafka-api-port> \ --tls-enabled \ --tls-truststore <path-to-kafka-api-ca-certificate>
kubectl -n redpanda exec -ti redpanda-0 -c redpanda -- \ rpk cluster info \ --brokers <broker-url>:<kafka-api-port>
You should see your new broker running with a new node ID.