Volume Snapshot
JuiceFS CSI Driver supports the CSI Volume Snapshot feature. You can use the VolumeSnapshot resource to create snapshots of JuiceFS volumes and restore data from snapshots.
Prerequisites
-
Kubernetes cluster version >= 1.17
-
Snapshot Controller and CRD installed
kubectl kustomize https://github.com/kubernetes-csi/external-snapshotter/client/config/crd | kubectl create -f -
kubectl kustomize https://github.com/kubernetes-csi/external-snapshotter/deploy/kubernetes/snapshot-controller | kubectl create -f - -
JuiceFS CSI Driver version >= 0.31.0
-
Snapshot feature enabled in JuiceFS CSI Driver Chart values:
snapshot:
enabled: true
How it works
JuiceFS CSI Driver uses the juicefs clone command to implement the snapshot feature.
-
Create a Snapshot: The CSI Driver starts a Job to clone the source directory to
.snapshots/<sourceVolumeID>/<snapshotID>directory. -
Restore a Snapshot: The CSI Driver starts a Job to clone the snapshot directory to the new PV directory.
-
Delete a Snapshot: The CSI Driver starts a Job to delete
.snapshots/<sourceVolumeID>/<snapshotID>directory.
Usage
1. Create a VolumeSnapshotClass
create a VolumeSnapshotClass.
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
name: juicefs-snapshot-class
driver: csi.juicefs.com
deletionPolicy: Delete
parameters:
csi.storage.k8s.io/snapshotter-secret-name: juicefs-secret
csi.storage.k8s.io/snapshotter-secret-namespace: kube-system
---
2. Create a VolumeSnapshot
Create a VolumeSnapshot resource to trigger snapshot creation.
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: my-snapshot
spec:
volumeSnapshotClassName: juicefs-snapshot-class
source:
persistentVolumeClaimName: my-pvc
3. Restore from a Snapshot
Create a new PVC and specify the snapshot in dataSource.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-restore-pvc
spec:
storageClassName: juicefs-sc
dataSource:
name: my-snapshot
kind: VolumeSnapshot
apiGroup: snapshot.storage.k8s.io
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
Notes
- Snapshot operations are asynchronous and executed by Kubernetes Jobs.
- Snapshot data is stored in the
.snapshotsdirectory of the JuiceFS file system. - Please ensure that the JuiceFS file system has enough space to store snapshot data.

