Skip to content

Commit 4e5e959

Browse files
Merge pull request #1135 from openshift-cherrypick-robot/cherry-pick-1121-to-release-0.9
[release-0.9] docs - pvc annotations for copy triggers
2 parents 9936dd8 + cac9cff commit 4e5e959

File tree

2 files changed

+209
-0
lines changed

2 files changed

+209
-0
lines changed

docs/usage/index.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Usage
88
permissionmodel
99
resourcerequirements
1010
triggers
11+
pvccopytriggers
1112
metrics/index
1213
rclone/index
1314
restic/index
@@ -57,6 +58,12 @@ Triggers
5758

5859
VolSync :doc:`supports several types of triggers <triggers>` to specify when to schedule the replication.
5960

61+
PVC Annotations for Copy Triggers
62+
=================================
63+
64+
VolSync :doc:`supports source PVC annotations <pvccopytriggers>` to coordinate triggering when VolSync takes a copy
65+
(snapshot or clone) for a replication.
66+
6067
Metrics
6168
=======
6269

docs/usage/pvccopytriggers.rst

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
=================================
2+
PVC annotations for copy triggers
3+
=================================
4+
5+
.. toctree::
6+
:hidden:
7+
8+
When doing a replication of a source PVC, it can be desirable to perform some operation such as a quiesce on the
9+
application source prior to performing the replication. VolSync has not implemented any hooks in order to do this
10+
as they can require privileges such as being able to exec into users containers.
11+
12+
A user can always schedule their replications themselves via manual triggers if they want to peform some automation,
13+
but now there's also the option of using annotations on the source PVC.
14+
15+
With a ``ReplicationSource`` that uses a CopyMode of ``Snapshot`` or ``Clone``, it's possible to use
16+
annotations on the Source PVC in order to coordinate when the snapshot or clone gets taken during a replication
17+
cycle.
18+
19+
When VolSync schedules a synchronization for the ``ReplicationSource``, if the source has the annotation
20+
``volsync.backube/use-copy-trigger``, then VolSync will pause before taking the Snapshot or Clone and wait for the user
21+
to indicate/trigger that VolSync can proceed. After which VolSync will also update via pvc annotations once the Snapshot
22+
or Clone is complete so that the user can choose to perform actions such as an unquiesce.
23+
24+
Source PVC annotations being used
25+
=================================
26+
27+
For the user to edit/modify (VolSync will not touch these annotations):
28+
29+
.. code-block:: console
30+
:caption: User-level Source PVC annotations
31+
32+
volsync.backube/use-copy-trigger
33+
volsync.backube/copy-trigger
34+
35+
For VolSync to edit/modify (Users should not modify these annotations):
36+
37+
.. code-block:: console
38+
:caption: VolSync Source PVC annotations
39+
40+
volsync.backube/latest-copy-status
41+
volsync.backube/latest-copy-trigger
42+
43+
Mover support
44+
=============
45+
46+
The current set of movers that support PVC annotations for copy triggers is:
47+
48+
- rclone
49+
- restic
50+
- rsync-tls
51+
- rsync
52+
53+
Example Source PVC annotation coordination with VolSync
54+
=======================================================
55+
56+
Here is an example scenario using a replicationsource with restic to backup a
57+
PVC to a remote store. PVC copy triggers will be used in order to coordinate
58+
performing actions on the application using the PVC prior to the snapshot
59+
being taken.
60+
61+
.. code-block:: yaml
62+
:caption: Example ReplicationSource
63+
64+
apiVersion: volsync.backube/v1alpha1
65+
kind: ReplicationSource
66+
metadata:
67+
name: test-rs
68+
namespace: test-ns
69+
spec:
70+
sourcePVC: data-pvc
71+
trigger:
72+
schedule: "*/30 * * * *"
73+
restic:
74+
pruneIntervalDays: 1
75+
repository: restic-secret
76+
retain:
77+
hourly: 3
78+
daily: 2
79+
monthly: 1
80+
copyMethod: Snapshot
81+
cacheCapacity: 1Gi
82+
83+
The example ``replicationsource`` will run a sync every 30 minutes and make a
84+
snapshot of the source PVC called ``data-pvc`` every time it syncs.
85+
86+
.. code-block:: yaml
87+
:caption: Source PVC
88+
89+
apiVersion: v1
90+
kind: PersistentVolumeClaim
91+
metadata:
92+
name: data-pvc
93+
namespace: test-ns
94+
annotations:
95+
# If this annotation is set with any value, VolSync will use copy triggers
96+
volsync.backube/use-copy-trigger: ""
97+
spec:
98+
accessModes: [ReadWriteOnce]
99+
resources:
100+
requests:
101+
storage: 10Gi
102+
103+
When the ``replicationsource`` runs a sync, it will see the ``volsync.backube/use-copy-trigger`` annotation
104+
on the source PVC and pause before taking a snapshot.
105+
106+
VolSync will then add the ``volsync.backube/latest-copy-status`` annotation with value ``WaitingForTrigger``.
107+
108+
.. code-block:: yaml
109+
:caption: Source PVC - VolSync is waiting for copy trigger before taking snapshot or clone
110+
111+
apiVersion: v1
112+
kind: PersistentVolumeClaim
113+
metadata:
114+
name: data-pvc
115+
namespace: test-ns
116+
annotations:
117+
volsync.backube/use-copy-trigger: ""
118+
volsync.backube/latest-copy-status: "WaitingForTrigger"
119+
...
120+
121+
At this point the user can run commands to pause or quiesce their application.
122+
123+
.. note::
124+
VolSync will update the ``replicationsource`` ``status.latestMoverStatus`` with an error if the use does not set a
125+
copy-trigger within 10 minutes of setting the ``volsync.backube/latest-copy-status`` to ``WaitingForTrigger``.
126+
VolSync will keep reconciling the ``replicationsource`` however.
127+
128+
Now to indicate that VolSync can proceed to create a copy of the source PVC (a snapshot or clone), the user needs to
129+
add the annotation ``volsync.backube/copy-trigger`` to a unique value.
130+
131+
.. code-block:: yaml
132+
:caption: Source PVC - User sets a new unique copy-trigger annotation on the PVC
133+
134+
apiVersion: v1
135+
kind: PersistentVolumeClaim
136+
metadata:
137+
name: data-pvc
138+
namespace: test-ns
139+
annotations:
140+
volsync.backube/use-copy-trigger: ""
141+
volsync.backube/copy-trigger: "trigger-1" # User updated to unique value
142+
volsync.backube/latest-copy-status: "WaitingForTrigger"
143+
...
144+
145+
VolSync will now start to make the copy of the PVC (a snapshot or clone) and update the
146+
``volsync.backube/latest-copy-status`` to ``InProgress``.
147+
148+
.. code-block:: yaml
149+
:caption: Source PVC - VolSync proceeds to take copy (snapshot or clone)
150+
151+
apiVersion: v1
152+
kind: PersistentVolumeClaim
153+
metadata:
154+
name: data-pvc
155+
namespace: test-ns
156+
annotations:
157+
volsync.backube/use-copy-trigger: ""
158+
volsync.backube/copy-trigger: "trigger-1"
159+
volsync.backube/latest-copy-status: "InProgress" # Snapshot is being taken
160+
...
161+
162+
One the snapshot or clone is complete, VolSync will again update the ``volsync.backube/latest-copy-status``, this time
163+
to ``Completed``. VolSync will also add another annotation ``volsync.backube/latest-copy-trigger`` which will match the
164+
value of the ``volsync.backube/copy-trigger`` set by the user.
165+
166+
.. code-block:: yaml
167+
:caption: Source PVC - VolSync has completed copy (snapshot or clone)
168+
169+
apiVersion: v1
170+
kind: PersistentVolumeClaim
171+
metadata:
172+
name: data-pvc
173+
namespace: test-ns
174+
annotations:
175+
volsync.backube/use-copy-trigger: ""
176+
volsync.backube/copy-trigger: "trigger-1"
177+
volsync.backube/latest-copy-status: "Completed" # Snapshot is complete
178+
volsync.backube/latest-copy-trigger: "trigger-1"
179+
...
180+
181+
VolSync will proceed to run the sync at this point, but since the copy has completed, users can now perform actions
182+
on their application such as an unquiesce.
183+
184+
Next sync iteration, VolSync will again update the ``volsync.backube/latest-copy-status`` to ``WaitingForTrigger``.
185+
186+
.. code-block:: yaml
187+
:caption: Source PVC - VolSync is again waiting for copy trigger before taking snapshot or clone
188+
189+
apiVersion: v1
190+
kind: PersistentVolumeClaim
191+
metadata:
192+
name: data-pvc
193+
namespace: test-ns
194+
annotations:
195+
volsync.backube/use-copy-trigger: ""
196+
volsync.backube/copy-trigger: "trigger-1"
197+
volsync.backube/latest-copy-status: "WaitingForTrigger" # The next sync is waiting for a new copy-trigger
198+
volsync.backube/latest-copy-trigger: "trigger-1"
199+
...
200+
201+
VolSync will wait before making a copy of the Source PVC until the user updates
202+
``volsync.backube/copy-trigger`` to a value that does not match the value of ``volsync.backube/latest-copy-trigger``.

0 commit comments

Comments
 (0)