Creating and Restoring Volume Snapshots in Thalassa Cloud Kubernetes
Volume snapshots provide point-in-time copies of persistent volumes, enabling you to back up data, restore previous states, and clone volumes for testing or development. Thalassa Cloud Kubernetes supports volume snapshots through the Kubernetes VolumeSnapshot API, allowing you to create snapshots of your persistent volumes and restore them when needed.
This guide explains how to create volume snapshots, restore volumes from snapshots, and use snapshots for backup and disaster recovery.
Prerequisites
Before creating volume snapshots, ensure a few things are in place. First, verify that your cluster has the VolumeSnapshot CRDs installed. Thalassa Cloud clusters include these by default, but you can check:
kubectl get crd | grep volumesnapshotYou should see CRDs for volumesnapshots.snapshot.storage.k8s.io and volumesnapshotcontents.snapshot.storage.k8s.io. If these aren’t present, the snapshot feature may not be enabled.
You’ll also need a VolumeSnapshotClass configured. Thalassa Cloud provides a default snapshot class. Check available snapshot classes:
kubectl get volumesnapshotclassYou should see a snapshot class, typically named tc-block or similar, that’s configured for Thalassa Cloud’s block storage.
Finally, you need a PersistentVolumeClaim (PVC) to snapshot. Snapshots are created from PVCs, so ensure you have a PVC with data you want to back up.
Checking Snapshot Classes
VolumeSnapshotClasses define how snapshots are created and where they’re stored. Thalassa Cloud provides a default snapshot class that’s configured for block storage snapshots.
List available snapshot classes:
kubectl get volumesnapshotclassGet details about the default snapshot class:
kubectl get volumesnapshotclass tc-block -o yamlThe snapshot class configuration shows the provisioner (which should be Thalassa Cloud’s CSI driver) and any parameters used for snapshot creation. The default class is typically sufficient for most use cases, but you can create custom snapshot classes if needed.
Creating a Volume Snapshot
Creating a volume snapshot is straightforward. You create a VolumeSnapshot resource that references the PVC you want to snapshot, and Kubernetes and the storage provider handle the rest.
First, identify the PVC you want to snapshot:
kubectl get pvcNote the name and namespace of the PVC you want to snapshot.
Create a VolumeSnapshot resource:
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: my-volume-snapshot
namespace: default
spec:
volumeSnapshotClassName: tc-block
source:
persistentVolumeClaimName: my-volumeThis creates a snapshot of the my-volume PVC using the tc-block snapshot class. Apply this resource:
kubectl apply -f snapshot.yamlKubernetes will create the snapshot, which typically takes a few seconds to a few minutes depending on the volume size and storage provider performance.
Monitoring Snapshot Creation
After creating a VolumeSnapshot, monitor its creation to ensure it completes successfully. Check the snapshot status:
kubectl get volumesnapshotThis shows all snapshots with their status. Look for the READYTOUSE column, which indicates whether the snapshot is ready to use. Initially, this will be false while the snapshot is being created.
Get detailed information about a specific snapshot:
kubectl describe volumesnapshot my-volume-snapshotThe describe output shows the snapshot’s status, including any conditions that indicate creation progress or errors. Look for conditions like ReadyToUse that show when the snapshot is complete.
Watch the snapshot to see status changes:
kubectl get volumesnapshot my-volume-snapshot -wThis watches the snapshot and shows updates as they occur, making it easy to see when creation completes.
Snapshot Readiness
Once the READYTOUSE status is true, the snapshot is complete and can be used to restore volumes. Snapshots are typically ready within seconds to minutes, depending on volume size.
Once the READYTOUSE status is true, the snapshot is complete and can be used to restore volumes.
Restoring a Volume from a Snapshot
Restoring a volume from a snapshot creates a new PVC with the data from the snapshot. This is useful for disaster recovery, creating test environments, or cloning volumes.
Create a new PVC that references the snapshot:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: restored-volume
namespace: default
spec:
storageClassName: tc-block
dataSource:
name: my-volume-snapshot
kind: VolumeSnapshot
apiGroup: snapshot.storage.k8s.io
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10GiThis creates a new PVC called restored-volume from the my-volume-snapshot snapshot. > [!NOTE] Restore Size Requirements
The
storagesize must be at least as large as the original volume, though it can be larger. You cannot restore to a smaller volume size.
Apply this PVC:
kubectl apply -f restore-pvc.yamlKubernetes will create a new volume from the snapshot. This process typically takes a few minutes, depending on the snapshot size.
Monitor the PVC creation:
kubectl get pvc restored-volumeThe PVC status will show Pending initially, then Bound once the volume is created and ready to use.
Using Restored Volumes
Once a volume is restored from a snapshot, you can use it like any other PVC. Mount it in pods, use it with StatefulSets, or attach it to any workload that needs persistent storage.
Create a pod that uses the restored volume:
apiVersion: v1
kind: Pod
metadata:
name: app-with-restored-volume
namespace: default
spec:
containers:
- name: app
image: nginx:1.25
volumeMounts:
- name: data
mountPath: /data
volumes:
- name: data
persistentVolumeClaim:
claimName: restored-volumeThis pod mounts the restored volume, giving you access to the data from the snapshot. The data will be exactly as it was when the snapshot was created.
Extra Information
To dive deeper into working with volume snapshots in Thalassa Cloud, check out the Volume Snapshots documentation. You can also learn more about persistent volumes and storage concepts in the Persistent Volumes documentation, and see practical examples of how to use volumes in workloads in the Deploying Applications guide. For a broader overview of Thalassa Cloud’s block storage features, refer to the Storage documentation.