第 32 章 Cluster recovery from persistent volumes
You can recover a Kafka cluster from persistent volumes (PVs) if they are still present.
32.1. Cluster recovery scenarios 复制链接链接已复制到粘贴板!
Recovering from PVs is possible in the following scenarios:
- Unintentional deletion of a namespace
- Loss of an entire OpenShift cluster while PVs remain in the infrastructure
The recovery procedure for both scenarios is to recreate the original PersistentVolumeClaim (PVC) resources.
32.1.1. Recovering from namespace deletion 复制链接链接已复制到粘贴板!
When you delete a namespace, all resources within that namespace—including PVCs, pods, and services—are deleted. If the reclaimPolicy for the PV resource specification is set to Retain, the PV retains its data and is not deleted. This configuration allows you to recover from namespace deletion.
PV configuration to retain data
apiVersion: v1
kind: PersistentVolume
# ...
spec:
# ...
persistentVolumeReclaimPolicy: Retain
Alternatively, PVs can inherit the reclaim policy from an associated storage class. Storage classes are used for dynamic volume allocation.
By configuring the reclaimPolicy property for the storage class, PVs created with this class use the specified reclaim policy. The storage class is assigned to the PV using the storageClassName property.
Storage class configuration to retain data
apiVersion: v1
kind: StorageClass
metadata:
name: gp2-retain
parameters:
# ...
# ...
reclaimPolicy: Retain
Storage class specified for PV
apiVersion: v1
kind: PersistentVolume
# ...
spec:
# ...
storageClassName: gp2-retain
When using Retain as the reclaim policy, you must manually delete PVs if you intend to delete the entire cluster.
32.1.2. Recovering from cluster loss 复制链接链接已复制到粘贴板!
If you lose the entire OpenShift cluster, all resources—including PVs, PVCs, and namespaces—are lost. However, it’s possible to recover if the physical storage backing the PVs remains intact.
To recover, you need to set up a new OpenShift cluster and manually reconfigure the PVs to use the existing storage.