VolSync is a Kubernetes operator that asynchronously replicates persistent volumes between clusters using rsync or rclone. It also supports creating backups of persistent volumes via restic.
Key Features:
- Asynchronous replication between Kubernetes clusters
- Multiple replication methods: rsync, rclone, restic
- Disaster recovery and data protection
- Cross-cluster data migration
- Backup and restore capabilities
Installation:
Install VolSync via Helm:
helm repo add backube https://backube.github.io/helm-charts/
helm install --create-namespace -n volsync-system volsync backube/volsync
Migrating Data into Kubernetes:
VolSync provides a CLI tool (kubectl-volsync) for migrating data from external storage into Kubernetes PersistentVolumes.
Step 1: Install VolSync CLI
Install the CLI using Krew:
kubectl krew install volsync
Step 2: Create Migration Destination
Create a namespace and migration destination:
kubectl create ns destination
kubectl volsync migration create -r mig-example \
--capacity 2Gi \
--accessmodes ReadWriteOnce \
--storageclass standard-csi \
--pvcname destination/mydata
This creates a 2Gi PVC named mydata in the destination namespace.
Step 3: Copy Data into PVC
Migrate data from external storage (e.g., local directory):
kubectl volsync migration rsync -r mig-example --source /tmp/data/
This synchronizes /tmp/data/ into the mydata PVC.
Step 4: Use Migrated Data
Deploy a pod to access the migrated data:
apiVersion: v1
kind: Pod
metadata:
name: data-consumer
namespace: destination
spec:
containers:
- name: data-consumer
image: busybox
command: ["/bin/sh", "-c", "sleep 3600"]
volumeMounts:
- mountPath: "/data"
name: mydata
volumes:
- name: mydata
persistentVolumeClaim:
claimName: mydata
Step 5: Clean Up
Remove migration resources after completion:
kubectl volsync migration delete -r mig-example
VolSync simplifies data migration and replication in Kubernetes environments, making it ideal for disaster recovery, multi-cluster deployments, and backup scenarios.
For detailed documentation and advanced usage, see the VolSync documentation and GitHub repository.