이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 34. Cluster recovery from persistent volumes
You can recover a Kafka cluster from persistent volumes (PVs) if they are still present.
34.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.
34.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
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
Storage class specified for PV
When using Retain as the reclaim policy, you must manually delete PVs if you intend to delete the entire cluster.
34.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.
34.2. Recovering a deleted KRaft-based Kafka cluster 링크 복사링크가 클립보드에 복사되었습니다!
This procedure describes how to recover a deleted Kafka cluster operating in KRaft mode from persistent volumes (PVs) by recreating the original PersistentVolumeClaim (PVC) resources.
If the Topic Operator and User Operator are deployed, you can recover KafkaTopic and KafkaUser resources by recreating them. It is important that you recreate the KafkaTopic resources with the same configurations, or the Topic Operator will try to update them in Kafka. This procedure shows how to recreate both resources.
If the User Operator is enabled and Kafka users are not recreated, users are deleted from the Kafka cluster immediately after recovery.
Before you begin
In this procedure, it is essential that PVs are mounted into the correct PVC to avoid data corruption. A volumeName is specified for the PVC and this must match the name of the PV.
For more information, see Section 10.5, “Configuring Kafka storage”.
Procedure
Check information on the PVs in the cluster:
oc get pv
oc get pvCopy to Clipboard Copied! Toggle word wrap Toggle overflow Information is presented for PVs with data.
Example PV output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
NAMEis the name of each PV. -
RECLAIMPOLICYshows that PVs are retained, meaning that the PV is not automatically deleted when the PVC is deleted. -
CLAIMshows the link to the original PVCs.
-
Recreate the original namespace:
oc create namespace myproject
oc create namespace myprojectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Here, we recreate the
myprojectnamespace.Recreate the original PVC resource specifications, linking the PVCs to the appropriate PV:
Example PVC resource specification
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the PV specifications to delete the
claimRefproperties that bound the original PVC.Example PV specification
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In the example, the following properties are deleted:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the Cluster Operator:
oc create -f install/cluster-operator -n myproject
oc create -f install/cluster-operator -n myprojectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Recreate all
KafkaTopicresources by applying theKafkaTopicresource configuration:oc apply -f <topic_configuration_file> -n myproject
oc apply -f <topic_configuration_file> -n myprojectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Recreate all
KafkaUserresources:If user passwords and certificates need to be retained, recreate the user secrets before recreating the
KafkaUserresources.If the secrets are not recreated, the User Operator will generate new credentials automatically. Ensure that the recreated secrets have exactly the same name, labels, and fields as the original secrets.
Apply the
KafkaUserresource configuration:oc apply -f <user_configuration_file> -n myproject
oc apply -f <user_configuration_file> -n myprojectCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Deploy the Kafka cluster using the original configuration for the
Kafkaresource. Add the annotationstrimzi.io/pause-reconciliation="true"to the original configuration for theKafkaresource, and then deploy the Kafka cluster using the updated configuration.oc apply -f <kafka_resource_configuration>.yaml -n myproject
oc apply -f <kafka_resource_configuration>.yaml -n myprojectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Recover the original
clusterIdfrom logs or copies of theKafkacustom resource. Otherwise, you can retrieve it from one of the volumes by spinning up a temporary pod.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the
Kafkaresource to set the.status.clusterIdwith the recovered value:oc edit kafka <cluster-name> --subresource status -n myproject
oc edit kafka <cluster-name> --subresource status -n myprojectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Unpause the
Kafkaresource reconciliation:oc annotate kafka my-cluster strimzi.io/pause-reconciliation=false \ --overwrite -n myproject
oc annotate kafka my-cluster strimzi.io/pause-reconciliation=false \ --overwrite -n myprojectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the recovery of the
KafkaTopicresources:oc get kafkatopics -o wide -w -n myproject
oc get kafkatopics -o wide -w -n myprojectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Kafka topic status
NAME CLUSTER PARTITIONS REPLICATION FACTOR READY my-topic-1 my-cluster 10 3 True my-topic-2 my-cluster 10 3 True my-topic-3 my-cluster 10 3 True
NAME CLUSTER PARTITIONS REPLICATION FACTOR READY my-topic-1 my-cluster 10 3 True my-topic-2 my-cluster 10 3 True my-topic-3 my-cluster 10 3 TrueCopy to Clipboard Copied! Toggle word wrap Toggle overflow KafkaTopiccustom resource creation is successful when theREADYoutput showsTrue.Verify the recovery of the
KafkaUserresources:oc get kafkausers -o wide -w -n myproject
oc get kafkausers -o wide -w -n myprojectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Kafka user status
NAME CLUSTER AUTHENTICATION AUTHORIZATION READY my-user-1 my-cluster tls simple True my-user-2 my-cluster tls simple True my-user-3 my-cluster tls simple True
NAME CLUSTER AUTHENTICATION AUTHORIZATION READY my-user-1 my-cluster tls simple True my-user-2 my-cluster tls simple True my-user-3 my-cluster tls simple TrueCopy to Clipboard Copied! Toggle word wrap Toggle overflow KafkaUsercustom resource creation is successful when theREADYoutput showsTrue.
34.3. Recovering a deleted ZooKeeper-based Kafka cluster 링크 복사링크가 클립보드에 복사되었습니다!
This procedure describes how to recover a deleted Kafka cluster operating in a ZooKeeper-based environment from persistent volumes (PVs) by recreating the original PersistentVolumeClaim (PVC) resources.
If the Topic Operator and User Operator are deployed, you can recover KafkaTopic and KafkaUser resources by recreating them. It is important that you recreate the KafkaTopic resources with the same configurations, or the Topic Operator will try to update them in Kafka. This procedure shows how to recreate both resources.
If the User Operator is enabled and Kafka users are not recreated, users are deleted from the Kafka cluster immediately after recovery.
Before you begin
In this procedure, it is essential that PVs are mounted into the correct PVC to avoid data corruption. A volumeName is specified for the PVC and this must match the name of the PV.
For more information, see Section 10.5, “Configuring Kafka storage”.
Procedure
Check information on the PVs in the cluster:
oc get pv
oc get pvCopy to Clipboard Copied! Toggle word wrap Toggle overflow Information is presented for PVs with data.
Example PV output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
NAMEis the name of each PV. -
RECLAIMPOLICYshows that PVs are retained, meaning that the PV is not automatically deleted when the PVC is deleted. -
CLAIMshows the link to the original PVCs.
-
Recreate the original namespace:
oc create namespace myproject
oc create namespace myprojectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Here, we recreate the
myprojectnamespace.Recreate the original PVC resource specifications, linking the PVCs to the appropriate PV:
Example PVC resource specification
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the PV specifications to delete the
claimRefproperties that bound the original PVC.Example PV specification
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In the example, the following properties are deleted:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the Cluster Operator:
oc create -f install/cluster-operator -n myproject
oc create -f install/cluster-operator -n myprojectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Recreate all
KafkaTopicresources by applying theKafkaTopicresource configuration:oc apply -f <topic_configuration_file> -n myproject
oc apply -f <topic_configuration_file> -n myprojectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Recreate all
KafkaUserresources:If user passwords and certificates need to be retained, recreate the user secrets before recreating the
KafkaUserresources.If the secrets are not recreated, the User Operator will generate new credentials automatically. Ensure that the recreated secrets have exactly the same name, labels, and fields as the original secrets.
Apply the
KafkaUserresource configuration:oc apply -f <user_configuration_file> -n myproject
oc apply -f <user_configuration_file> -n myprojectCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Deploy the Kafka cluster using the original configuration for the
Kafkaresource.oc apply -f <kafka_resource_configuration>.yaml -n myproject
oc apply -f <kafka_resource_configuration>.yaml -n myprojectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the recovery of the
KafkaTopicresources:oc get kafkatopics -o wide -w -n myproject
oc get kafkatopics -o wide -w -n myprojectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Kafka topic status
NAME CLUSTER PARTITIONS REPLICATION FACTOR READY my-topic-1 my-cluster 10 3 True my-topic-2 my-cluster 10 3 True my-topic-3 my-cluster 10 3 True
NAME CLUSTER PARTITIONS REPLICATION FACTOR READY my-topic-1 my-cluster 10 3 True my-topic-2 my-cluster 10 3 True my-topic-3 my-cluster 10 3 TrueCopy to Clipboard Copied! Toggle word wrap Toggle overflow KafkaTopiccustom resource creation is successful when theREADYoutput showsTrue.Verify the recovery of the
KafkaUserresources:oc get kafkausers -o wide -w -n myproject
oc get kafkausers -o wide -w -n myprojectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Kafka user status
NAME CLUSTER AUTHENTICATION AUTHORIZATION READY my-user-1 my-cluster tls simple True my-user-2 my-cluster tls simple True my-user-3 my-cluster tls simple True
NAME CLUSTER AUTHENTICATION AUTHORIZATION READY my-user-1 my-cluster tls simple True my-user-2 my-cluster tls simple True my-user-3 my-cluster tls simple TrueCopy to Clipboard Copied! Toggle word wrap Toggle overflow KafkaUsercustom resource creation is successful when theREADYoutput showsTrue.