'Restore a single StatefulSet pod's PersistentVolume using a VolumeSnapshot
Hi we're looking for a way to restore a VolumeSnapshot to a single pod of a StatefulSet without scaling down the StatefulSet.
I think it might be doable by deleting the PersistentVolumeClaim, PersistentVolume, and then pod, and making sure a new pvc is available with the right name.
Is there another more direct way to do this? In kubernetes, is it safe to reprovision things like PVs by destroying them and expecting the controller to recreate the resources (is this approach fundamentally safe)?
Thanks.
Solution 1:[1]
The answer: Yes it is. There are several approaches:
- The approach above: prepare the PVC ahead of time as described, or
- Set the dataSource field in the statefulset to be a volume snapshot. To restore a replica, simply delete the pvc and the pod, and when the pod is reinitialized it will restore from the snapshot. You will need to delete and recreate this volume snapshot to update the "active" snapshot however - its not possible to modify the value of the volumeClaimTemplates after the stateful set is created.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | corsair |
