Rok Snapshots

Rok snapshots allow you to instantly snapshot your Rok volumes to create a point-in-time copy of your data for local and offsite backups. Rok takes immutable, group consistent snapshots of your applications and stores these snapshots in a backup store, for example, Amazon S3.

Combine this with Rok’s instant cloning, and you can recover from hardware failure in minutes, regardless of the volume’s capacity.

To take a volume snapshot, use the rok volume snapshot class:

apiVersion: snapshot.storage.k8s.io/v1beta1 kind: VolumeSnapshotClass metadata: name: rok parameters: # NOTE: Increase this in case of heavy I/O during snapshots rok/snapshot-cow-size: 1GiB driver: rok.arrikto.com deletionPolicy: Delete

Parameters

If the pre-defined volume snapshot class doesn’t meet your requirements, you can create your own customized volume snapshot class, based on the pre-defined one.

Rok supports the following volume snapshot class parameters to further customize Rok snapshots:

  • rok/snapshot-chunk-size
    • Type: string
    • Values: size string
    • Default: “128KiB”

    The chunk size for snapshots. It defines the unit of Copy On Write for snapshots. The value must be a power of 2 between 4KiB and 512KiB.

  • rok/snapshot-cow-size
    • Type: string
    • Values: size string
    • Default: “10GiB”

    The size of the snapshot Copy On Write space. Increase this in case of heavy I/O during snapshots.

  • rok/pre-snapshot-verification
    • Type: string
    • Values: “true” | “false”
    • Default: “true”

    Verify the integrity of the filesystem on the volume, before taking a snapshot. If the filesystem has errors, Rok refuses to snapshot the volume.

  • rok/post-snapshot-verification
    • Type: string
    • Values: “true” | “false”
    • Default: “false”

    Verify the integrity of the filesystem in the snapshot, after creating it. This is an expensive operation that runs a full filesystem check, and may induce additional costs, since it access the snapshot data in the snapshot store, for example, S3.

Note

To affect only a specific Rok snapshot you can specify any of the volume snapshot class parameters as a VolumeSnapshot annotation.

Snapshot PVC Backed by Rok

Create a VolumeSnapshot object and set the VolumeSnapshotClass to rok:

apiVersion: snapshot.storage.k8s.io/v1beta1 kind: VolumeSnapshot metadata: name: mysnap spec: volumeSnapshotClassName: rok source: persistentVolumeClaimName: mypvc

Create Volume from a Kubernetes Snapshot

You can create a PVC from a Kubernetes VolumeSnapshot object. You need to have created this object using the rok volume snapshot class.

Create a PVC object and set dataSource to point to the Rok snapshot:

apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mysnap-pvc spec: storageClassName: rok dataSource: name: mysnap kind: VolumeSnapshot apiGroup: snapshot.storage.k8s.io accessModes: - ReadWriteOnce resources: requests: storage: 1Gi

Create PVC from a Rok Resource

Create a new PVC and set the rok/origin PVC annotation to the URL of the Rok object:

kind: PersistentVolumeClaim apiVersion: v1 metadata: name: mypvc annotations: rok/origin: https://example.com/swift/v1/<object-url> spec: storageClassName: rok accessModes: - ReadWriteOnce resources: requests: storage: 1Gi

Create StatefulSet from a Rok Group Resource

Rok supports passing a group resource as a rok/origin for a PVC. This is useful when you want to create a StatefulSet with a volumeClaimTemplate and assign a unique disk from a group resource to each Pod.

An example StatefulSet looks like this:

apiVersion: apps/v1 kind: StatefulSet metadata: name: web spec: serviceName: "nginx" replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: k8s.gcr.io/nginx-slim:0.8 ports: - containerPort: 80 name: web volumeMounts: - name: www mountPath: /usr/share/nginx/html volumeClaimTemplates: - metadata: name: www annotations: rok/origin: https://example.com/swift/v1/<group-object-url> spec: storageClassName: rok accessModes: [ "ReadWriteOnce" ] resources: requests: storage: 1Gi

The order of the resources within the group is important, as each Pod will get the corresponding disk (e.g., web-0 will get the first object from the group, web-1 the second one, etc.).

If the number of replicas of the StatefulSet exceeds the number of the objects in the group, the extra Pods will get an empty disk.