Deploying Snapshot and Clones Workloads
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.
For Helm to deploy the snaps chart in stages, we introduce the mandatory variable snaps.stage
The chart supports the following stages:
- snapshot-class
- example-pvc
- snapshot-from-pvc
- pvc-from-snapshot
- pvc-from-pvc
Stage 1: Create VolumeSnapshotClass
Create a VolumeSnapshotClass:
helm install \ --set snaps.enabled=true \ --set snaps.stage=snapshot-class \ lb-csi-workload-snaps-snapshot-class \ lightbits-helm-repo/lb-csi-workload-examplesStage 2: Create Example PVC and POD
Running the following command:
helm install \ --set snaps.enabled=true \ --set snaps.stage=example-pvc \ lb-csi-workload-snaps-example-pvc \ lightbits-helm-repo/lb-csi-workload-examplesWill output:
NAME: lb-csi-workload-snaps-example-pvcLAST DEPLOYED: Sun Feb 21 16:09:02 2021NAMESPACE: defaultSTATUS: deployedREVISION: 1TEST SUITE: NoneVerify that PV, PVC are created and in Bounded state, and that POD is in Running state.
kubectl get pv,pvc,podsNAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGEpersistentvolume/pvc-797e45c0-2333-47ce-9a5e-2bb46b101163 10Gi RWO Delete Bound default/example-pvc example-sc 57sNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGEpersistentvolumeclaim/example-pvc Bound pvc-797e45c0-2333-47ce-9a5e-2bb46b101163 10Gi RWO example-sc 58sNAME READY STATUS RESTARTS AGEpod/example-pod 1/1 Running 0 58sStage 3: Take a Snapshot from the PVC created in Stage 2
Create a snapshot from the previously created PVC named example-pvc.
helm install \ --set snaps.enabled=true \ --set snaps.stage=snapshot-from-pvc \ lb-csi-workload-snaps-snapshot-from-pvc \ lightbits-helm-repo/lb-csi-workload-examplesWill output:
NAME: lb-csi-workload-snaps-snapshot-from-pvcLAST DEPLOYED: Tue Feb 23 13:11:16 2021NAMESPACE: defaultSTATUS: deployedREVISION: 1TEST SUITE: NoneVerify that VolumeSnapshot and VolumeSnapshotContent were created, and READYTOUSE status is true.
kubectl get VolumeSnapshot,VolumeSnapshotContentNAME READYTOUSE SOURCEPVC SOURCESNAPSHOTCONTENT RESTORESIZE SNAPSHOTCLASS SNAPSHOTCONTENT CREATIONTIME AGEvolumesnapshot.snapshot.storage.k8s.io/example-snapshot true example-pvc 10Gi example-snapshot-sc snapcontent-b710e398-eaa5-45be-bbdc-db74d799e5cc 3m40s 3m49sNAME READYTOUSE RESTORESIZE DELETIONPOLICY DRIVER VOLUMESNAPSHOTCLASS VOLUMESNAPSHOT AGEvolumesnapshotcontent.snapshot.storage.k8s.io/snapcontent-b710e398-eaa5-45be-bbdc-db74d799e5cc true 10737418240 Delete csi.lightbitslabs.com example-snapshot-sc example-snapshot 3m49sStage 4: Create a PVC from the Snapshot created in Stage 3 and create a POD that uses it
Create a PVC from the previously taken Snapshot named example-snapshot.
helm install \ --set snaps.enabled=true \ --set snaps.stage=pvc-from-snapshot \ lb-csi-workload-snaps-pvc-from-snapshot \ lightbits-helm-repo/lb-csi-workload-examplesWill output:
NAME: lb-csi-workload-snaps-pvc-from-snapshotLAST DEPLOYED: Tue Feb 23 13:16:26 2021NAMESPACE: defaultSTATUS: deployedREVISION: 1TEST SUITE: NoneVerify that PV, PVC are created and in Bounded state, and that POD is in Running state.
kubectl get pv,pvc,podNAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGEpersistentvolume/pvc-797e45c0-2333-47ce-9a5e-2bb46b101163 10Gi RWO Delete Bound default/example-pvc example-sc 18mpersistentvolume/pvc-d1d20d2b-7fdd-4775-9107-ab8129841a74 10Gi RWO Delete Bound default/example-pvc-from-snapshot example-sc 2m24sNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGEpersistentvolumeclaim/example-pvc Bound pvc-797e45c0-2333-47ce-9a5e-2bb46b101163 10Gi RWO example-sc 18mpersistentvolumeclaim/example-pvc-from-snapshot Bound pvc-d1d20d2b-7fdd-4775-9107-ab8129841a74 10Gi RWO example-sc 2m25sNAME READY STATUS RESTARTS AGEpod/example-pod 1/1 Running 0 18mpod/example-pvc-from-snapshot-pod 1/1 Running 0 2m25sWe see the PV, PVC and PODs from Stage #2 as well.
Stage 5: Create a PVC from the PVC created in Stage 3 and create a POD that uses it
Create a PVC from the previously taken Snapshot named example-snapshot.
helm install \ --set snaps.enabled=true \ --set snaps.stage=pvc-from-pvc \ lb-csi-workload-snaps-pvc-from-pvc \ lightbits-helm-repo/lb-csi-workload-examplesWill output:
NAME: lb-csi-workload-snaps-pvc-from-pvcLAST DEPLOYED: Tue Feb 23 13:16:26 2021NAMESPACE: defaultSTATUS: deployedREVISION: 1TEST SUITE: NoneVerify that PV, PVC were created and in Bounded state, and that POD is in Running state.
kubectl get pv,pvc,podNAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGEpersistentvolume/pvc-1fe22ed7-3b7e-4094-95a3-995538659c51 10Gi RWO Delete Bound default/example-pvc-from-pvc example-sc 15spersistentvolume/pvc-797e45c0-2333-47ce-9a5e-2bb46b101163 10Gi RWO Delete Bound default/example-pvc example-sc 5h53mpersistentvolume/pvc-d1d20d2b-7fdd-4775-9107-ab8129841a74 10Gi RWO Delete Bound default/example-pvc-from-snapshot example-sc 5h36mNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGEpersistentvolumeclaim/example-pvc Bound pvc-797e45c0-2333-47ce-9a5e-2bb46b101163 10Gi RWO example-sc 5h53mpersistentvolumeclaim/example-pvc-from-pvc Bound pvc-1fe22ed7-3b7e-4094-95a3-995538659c51 10Gi RWO example-sc 23spersistentvolumeclaim/example-pvc-from-snapshot Bound pvc-d1d20d2b-7fdd-4775-9107-ab8129841a74 10Gi RWO example-sc 5h36mNAME READY STATUS RESTARTS AGEpod/example-pod 1/1 Running 0 5h53mpod/example-pvc-from-pvc-pod 1/1 Running 0 23spod/example-pvc-from-snapshot-pod 1/1 Running 0 5h36mWe see the PV, PVC and PODs from Stages #2 and #4 as well.
Stage 6: Uninstall Snapshot Workloads
If we list the releases installed, we will see:
helm lsNAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSIONlb-csi-workload-sc default 1 2021-02-23 08:06:39.915046 +0200 IST deployed lb-csi-workload-examples-0.1.0 1.4.0 lb-csi-workload-snaps-example-pvc default 1 2021-02-23 12:59:55.458252038 +0200 IST deployed lb-csi-workload-examples-0.1.0 1.4.0 lb-csi-workload-snaps-pvc-from-pvc default 1 2021-02-23 18:52:41.391731359 +0200 IST deployed lb-csi-workload-examples-0.1.0 1.4.0 lb-csi-workload-snaps-pvc-from-snapshot default 1 2021-02-23 13:16:26.020897186 +0200 IST deployed lb-csi-workload-examples-0.1.0 1.4.0 lb-csi-workload-snaps-snapshot-from-pvc default 1 2021-02-23 13:11:16.746865829 +0200 IST deployed lb-csi-workload-examples-0.1.0 1.4.0The 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:
helm uninstall lb-csi-workload-snaps-pvc-from-pvcIn order to verify that all resources are deleted, the following command should return no entry:
kubectl get pv,pvc,pod | grep pvc-from-pvcUninstall pvc-from-snapshot:
helm uninstall lb-csi-workload-snaps-pvc-from-snapshotIn order to verify that all resources are deleted, the following command should return no entry:
kubectl get pv,pvc,pod | grep pvc-from-snapshotUninstall snapshot-from-pvc:
helm uninstall lb-csi-workload-snaps-snapshot-from-pvcIn order to verify that all resources are deleted, the following command should return no entry:
kubectl get VolumeSnapshot,VolumeSnapshotContent | grep snapshot-from-pvcUninstall example-pvc:
helm uninstall lb-csi-workload-snaps-example-pvcVerify that all resources are gone:
kubectl get pv,pvc,podsNo resources found in default namespace.Delete VolumeSnapshotClass:
helm uninstall lb-csi-workload-snaps-snapshot-class