Skip to main content
Version: 23.1

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.

Prerequisites

  • A running Redpanda deployment on a Kubernetes cluster.

  • PersistentVolumes for either the Redpanda data directory or the Tiered Storage cache.

Delete a PersistentVolume

To delete a PersistentVolume, follow these steps to ensure that your data is moved to other brokers in the cluster.

  1. Identify the PV that you want to delete:

    kubectl get persistentvolume
  2. 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.

  3. Delete the PVC that is bound to your PV:

    kubectl delete persistentvolumeclaim <pvc-name> -n redpanda
  4. If the reclaimPolicy of your PV is not Delete, delete the PV:

    kubectl delete persistentvolume <pv-name>
  5. 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 Redpanda data directory, the Pod will have a new PVC bound to a PV that is set in storage.persistentVolume.storageClass. See Use PersistentVolumes.

    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.

  6. 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>

    You should see your new broker running with a new node ID.

Suggested reading

What do you like about this doc?




Optional: Share your email address if we can contact you about your feedback.

Let us know what we do well: