Working with Volume Snapshots
In Thalassa Cloud, you can create snapshots of persistent volumes to back up your data or restore a previous state. Snapshots provide a point-in-time copy of a volume, allowing you to recover from accidental data loss, perform system rollbacks, or migrate data across environments. These snapshots are managed using the VolumeSnapshot resource, which interacts with a VolumeSnapshotClass to determine how and where snapshots are stored.
Available Snapshot Classes
A VolumeSnapshotClass defines the backend storage driver and configuration used for creating snapshots. Each Thalassa Cloud Kubernetes cluster comes with a default snapshot class, named tc-block, which is linked to Thalassa Cloud’s block storage solution. The snapshot class ensures that snapshots are created in a consistent, storage-optimized manner.
To list available snapshot classes in your cluster, run the following command:
kubectl get volumesnapshotclassIf you are using a custom deployment of Thalassa Cloud or a specific region, the snapshot class name may differ. If no snapshot classes are available, ensure that the CSI snapshot feature is enabled and properly configured for your storage provider.
Creating a Volume Snapshot
A Persistent Volume Claim (PVC) represents a storage volume used by a workload. Before creating a snapshot, you must have a PVC that you want to snapshot. Below is an example of a PVC definition:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-volume
namespace: default
spec:
accessModes:
- ReadWriteOnce
storageClassName: block
resources:
requests:
storage: 1GiOnce you have a PVC, you can create a VolumeSnapshot resource. This will generate a snapshot of the specified PVC, preserving its state at the moment of creation:
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: my-snapshot
namespace: default
spec:
volumeSnapshotClassName: block
source:
persistentVolumeClaimName: my-volumeApply the snapshot definition using:
kubectl apply -f snapshot.yamlChecking Snapshot Status
Once the snapshot request is submitted, you can verify its status by running:
kubectl get volumesnapshot -AExample output:
NAMESPACE NAME READYTOUSE SOURCEPVC SNAPSHOTCLASS CREATIONTIME AGE
default my-snapshot true my-volume block 5m 5mIf the READYTOUSE column shows true, the snapshot is successfully created and can be used for restoring a new volume.
Restoring a Snapshot
Restoring a snapshot allows you to create a new Persistent Volume Claim (PVC) from a previously saved snapshot. This is useful for disaster recovery, cloning environments, or testing application changes without affecting the original volume.
To restore a volume from a snapshot, define a PVC that references the snapshot in its dataSource field:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: test-snapshot-restore
namespace: default
spec:
storageClassName: block
dataSource:
name: my-snapshot
kind: VolumeSnapshot
apiGroup: snapshot.storage.k8s.io
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1GiApply the restore configuration:
kubectl apply -f restore.yamlRestoration Considerations
- Time to Restore: The process may take several minutes, depending on the snapshot size and storage backend performance.
- Data Integrity: The restored volume retains the exact state of the original PVC at the moment the snapshot was created. This means if the filesystem on the snapshotted volume was corrupt during snapshot creation, it will also be corrupt on the restored volume.