Volume Snapshot and Clones Provisioning Examples

This example is more complex and is composed of six different stages:

  • Stage 1: Create VolumeSnapshotClass.
  • Stage 2: Create Example PVC and POD.
  • Stage 3: Take a Snapshot from the PVC created in Stage #2.
  • Stage 4: Create a PVC from the Snapshot created in Stage #3 and create a POD that uses it.
  • Stage 5: Create a PVC from the PVC created in Stage #4 and create a POD that uses it.
  • Stage 6: Uninstall Snapshot Workloads.

The examples are dependent on one another, so you must run them in order.

Stage 1: Create VolumeSnapshotClass

Create a VolumeSnapshotClass:

Bash
Copy

Stage 2: Create Example PVC and POD

Running the following command:

Bash
Copy

Verify that PV, PVC are created and in Bounded state and POD is in Running state.

Bash
Copy

Stage 3: Take a Snapshot from the PVC created in Stage #2

Create a snapshot from the previously created PVC named example-pvc.

Bash
Copy

Verify that VolumeSnapshot and VolumeSnapshotContent were created, and that READYTOUSE status is true.

Bash
Copy

Stage 4: Create a PVC from the Snapshot created in stage #3, and create a POD that uses it

After your VolumeSnapshot object is bound, you can use that object to provision a new volume that is pre-populated with data from the snapshot.

The volume snapshot content object is used to restore the existing volume to a previous state.

Create a PVC from the previously taken Snapshot named example-snapshot:

Bash
Copy

Verify that PV, PVC were created and in Bounded state, and that POD is in Running state.

Bash
Copy

We see the PV, PVC and PODs from Stage #2 as well.

Stage 5: Create a PVC from the PVC we created in stage #4, and create a POD that uses it

Create a PVC from the previously taken Snapshot named example-snapshot.

Bash
Copy

Verify that PV, PVC were created and in Bounded state, and that POD is in Running state.

Bash
Copy

We see the PV, PVC and PODs from Stages #2 and #4 as well.

Stage 6: Uninstall Snapshot Workloads

Note: Installation must be in reverse order of the deployment.

After each uninstall, we need to verify that all related resources were released before continuing to the next uninstall.

Uninstall pvc-from-pvc:

Bash
Copy

In order to verify that all resources are deleted, the following command should not generate any output:

Bash
Copy

Uninstall pvc-from-snapshot:

Bash
Copy

In order to verify that all resources are deleted, the following command should not generate any output:

Bash
Copy

Uninstall snapshot-from-pvc:

Bash
Copy

In order to verify that all resources are deleted, the following command should not generate any output:

Bash
Copy

Uninstall example-pvc:

Bash
Copy

Verify that all resources are gone:

Bash
Copy

Delete VolumeSnapshotClass:

Bash
Copy
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard