Configure 3DSnaps in OpenShift vSphere
Summary and Key concepts
Summary This article explains how to configure 3DSnaps in Portworx, allowing users to run pre- and post-snapshot rules on application pods. These rules can quiesce the application (e.g., flush tables or lock databases) before a snapshot and resume operations after the snapshot. The process involves creating Stork rules (which define the actions and pods to be affected) and then referencing those rules in VolumeSnapshot or GroupVolumeSnapshot objects. Several example rules are provided for applications like MySQL, MongoDB, and Cassandra, showing how to perform pre- and post-snapshot operations using commands. The article also covers how to verify and restore snapshots.
Kubernetes Concepts
- VolumeSnapshot: Allows users to take snapshots of PersistentVolumes, with pre- and post-snapshot rules applied for quiescing and resuming applications.
- PersistentVolumeClaim (PVC): The snapshots apply to the volumes managed by PVCs in Kubernetes.
- Custom Resource Definition (CRD): The Stork
Rule
CRD defines the pre- and post-snapshot operations in this workflow.
Portworx Concepts
-
Stork: A tool used to manage storage operations, including executing pre- and post-snapshot rules during snapshot creation.
-
Group Snapshots: A feature allowing users to take a snapshot of multiple volumes at once, typically used with pre- and post-execution rules.
For each of the snapshot types, Portworx supports specifying pre and post rules that are run on the application pods using the volumes being snapshotted. This allows users to quiesce the applications before the snapshot is taken and resume I/O after the snapshot is taken.
The high level workflow for configuring 3DSnaps involves creating rules and later on referencing the rules when creating the snapshots.
Step 1: Create Rules
A Stork Rule
is a Custom Resource Definition (CRD) that allows to define actions that get performed on pods matching selectors. Below are the supported fields:
- podSelector: The actions will get executed on pods that only match the label selectors given here.
- actions: This contains a list of actions to be performed. Below are supported fields under actions:
- type: The type of action to run. Only type command is supported.
- background: If true, the action will run in background and will be terminated by Stork after the snapshot has been initiated. If false, the action will first complete and then the snapshot will get initiated.
- If background is set to true, add
${WAIT_CMD}
as shown in the examples below. This is a placeholder and Stork will replace it with an appropriate command to wait for the command is done.
- If background is set to true, add
- value: This is the actual action content. For example, the command to run.
- runInSinglePod: If true, the action will be run on a single pod that matches the selectors.
- container: specifies the container in which Stork will execute the action.
Step 2: Create snapshots that reference the rules
Once you have the rules applied in your cluster, you can reference them in the VolumeSnapshot
or GroupVolumeSnapshot
for individual and group snapshots respectively.
VolumeSnapshots
Use following annotations on the VolumeSnapshot to specify pre and post rules.
- stork.rule/pre-snapshot: Stork will execute the rule which is given in the value of this annotation before taking the snapshot.
- stork.rule/post-snapshot: Stork will execute the rule which is given in the value of this annotation after taking the snapshot.
GroupVolumeSnapshots
Use following fields in the GroupVolumeSnapshot spec to specify pre and post rules.
- preExecRule: Stork will execute the rule which is given in the value of this annotation before taking the group snapshot.
- postExecRule: Stork will execute the rule which is given in the value of this annotation after taking the snapshot.
Examples
This section covers examples of creating 3DSnapshots for various applications.