⚠️ Work in Progress
You are viewing development documentation built from the latest commit on main. APIs and features are subject to change.

VolSync Builders

VolSync Builders - ReplicationSource and ReplicationDestination

Go Reference Go Reference

The volsync package provides strongly-typed constructor functions for VolSync (volsync.backube/v1alpha1) resources. It is the canonical entry point for building ReplicationSource and ReplicationDestination objects in kure.

Overview

VolSync replicates persistent volume data between Kubernetes clusters. Each replication direction (source and destination) selects exactly one mover — the data-transfer backend — from a sum of choices: Restic, Rsync (legacy SSH), RsyncTLS, Rclone, Syncthing (source-only), or an External passthrough.

This package encodes the mover one-of as a sealed-interface sum type: Mover on the parent Config holds exactly one variant. Setting two movers is a compile error; setting none is detected at construction. See docs/ARCHITECTURE.md § One-of Constraints for the rationale.

Supported Resources

ResourceMovers
ReplicationSourceRestic · Rsync · RsyncTLS · Rclone · Syncthing · External
ReplicationDestinationRestic · Rsync · RsyncTLS · Rclone · External

ReplicationSource

import (
    volsyncv1alpha1 "github.com/backube/volsync/api/v1alpha1"

    "github.com/go-kure/kure/pkg/kubernetes/volsync"
)

schedule := "@hourly"
rs := volsync.ReplicationSource(&volsync.ReplicationSourceConfig{
    Name:      "db-backup",
    Namespace: "data",
    SourcePVC: "postgres-data",
    Trigger:   &volsync.TriggerConfig{Schedule: &schedule},
    Mover: &volsync.SourceResticConfig{
        Repository: "restic-creds",
        ReplicationSourceVolumeOptions: volsyncv1alpha1.ReplicationSourceVolumeOptions{
            CopyMethod: volsync.CopyMethodSnapshot,
        },
        Retain: &volsyncv1alpha1.ResticRetainPolicy{
            Daily:   ptr.Int32(7),
            Weekly:  ptr.Int32(4),
            Monthly: ptr.Int32(12),
        },
    },
})

ReplicationDestination

rd := volsync.ReplicationDestination(&volsync.ReplicationDestinationConfig{
    Name:      "db-restore",
    Namespace: "dr",
    Trigger:   &volsync.TriggerConfig{Manual: "restore-1"},
    Mover: &volsync.DestinationResticConfig{
        Repository: "restic-creds",
        ReplicationDestinationVolumeOptions: volsyncv1alpha1.ReplicationDestinationVolumeOptions{
            CopyMethod:  volsync.CopyMethodSnapshot,
            Capacity:    resource.MustParse("10Gi").DeepCopy(),
            AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},
        },
    },
})

Movers

MoverPurpose
ResticEncrypted, deduplicated snapshots to a restic repository (S3, B2, etc.).
RsyncLegacy SSH-based rsync. Prefer RsyncTLS for new deployments.
RsyncTLSrsync over a TLS pre-shared key.
RcloneSync to/from any rclone-supported backend (S3, GCS, Azure, etc.).
SyncthingContinuous bidirectional sync over the Syncthing protocol (source resource only).
ExternalPassthrough for custom replication providers — opaque provider + parameters.

Modifier Functions

// Trigger
volsync.SetReplicationSourceSchedule(rs, "@daily")
volsync.SetReplicationSourceManualTrigger(rs, "go")
volsync.SetReplicationDestinationSchedule(rd, "@weekly")
volsync.SetReplicationDestinationManualTrigger(rd, "go")

// Spec fields
volsync.SetReplicationSourceSourcePVC(rs, "data")
volsync.SetReplicationSourcePaused(rs, true)
volsync.SetReplicationDestinationPaused(rd, true)

// Replace mover (clears any existing mover first)
volsync.SetReplicationSourceMover(rs, &volsync.SourceRcloneConfig{ /* ... */ })
volsync.SetReplicationDestinationMover(rd, &volsync.DestinationResticConfig{ /* ... */ })

// Syncthing peers
volsync.AddSyncthingPeer(syncCfg, "tcp://peer:22000", "PEER-ID", false)