How to Create and Restore from Snapshots of Volumes Used in Kubernetes Clusters

Validated on August 20, 2019 &bullet;
Posted on August 20, 2019

Prerequisite

You must have an existing volume in use in your cluster, which you can create by creating a PersistentVolumeClaim (PVC). For the purposes of this tutorial, presume we have already created a PVC by calling kubectl create -f your_pvc_file.yaml with a YAML file that looks like this:

Restore from a snapshot:

To restore from a given snapshot, you need to create a new PVC that refers to the snapshot by calling kubectl create -f your_restore_file.yaml. Here’s an example of a YAML file that restores from a snapshot and creates a new PVC for use in the cluster: