Bootstrap FreeKB - OpenShift - Create Volume Snapshot
OpenShift - Create Volume Snapshot

Updated:   |  OpenShift articles

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

If you are not familiar with Volume Snapshots, check out my article OpenShift - Getting Started with Volume Snapshots.

This assumes you have already

The oc get VolumeSnapshotClasses command can be used to list the Volume Snapshot Classes you have created. Let's say you have a Volume Snapshot Class named csi-vsphere-vsc.

]$ oc get VolumeSnapshotClasses
NAME              DRIVER                   DELETIONPOLICY   AGE
csi-vsphere-vsc   csi.vsphere.vmware.com   Delete           2m5s

 

The oc get PersistentVolumeClaims command can be used to list your Persistent Volume Claims. Let's say you have a Persistent Volume Claim named my-pvc.

TIP

The -A or --all-namespaces flag can be used to list the Persistent Volume Claims in every project / namespace.

The -n or --namespace flag can be used to list the Persistent Volume Claims in a certain project / namespace.

 

]$ oc get persistentvolumeclaims --namespace my-project
NAME       STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   VOLUMEATTRIBUTESCLASS   AGE
my-pvc    Bound     pvc-819117a8-1a79-4be6-b9e7-620845979db6   1Gi        RWO            thin-cli       <unset>                 4d23h

 

Let's say you have the following in a YAML file. In this example, Persistent Volume Claim my-pvc is using Storage Class thin-csi and Storage Class thin-csi maps to provisioner csi.vsphere.vmware.com and the name of the Volume Snapshot Classes is csi-vsphere-vsc thus csi-vsphere-vsc is used for the volumeSnapshotClassName.

apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
  name: my-volume-snapshot
  namespace: my-project
spec:
  volumeSnapshotClassName: csi-vsphere-vsc
  source:
    persistentVolumeClaimName: my-pvc

 

The oc apply command can be used to create the Volume Snapshot.

~]$ oc apply --filename my-volume-snapshot.yaml
volumesnapshot.snapshot.storage.k8s.io/my-volume-snapshot created

 

Or in the OpenShift console, at Storage > VolumeSnapshots > Create VolumeSnapshot.

 

The oc get volumesnaphot command can then be used to confirm the Volume Snapshot has been created. It is important to recognize that the Volume Snapshot does not actually contain the content of the volume. Instead, the Volume Snapshot Content contains the actual content of the volume. The Volume Snapshot is like the parent resource that ultimately attempts to create the Volume Snapshot Content.

]$ oc get volumesnapshots --namespace my-project
NAME                 READYTOUSE   SOURCEPVC   SOURCESNAPSHOTCONTENT   RESTORESIZE   SNAPSHOTCLASS     SNAPSHOTCONTENT                                    CREATIONTIME   AGE
my-volume-snapshot   true         my-pvc                              1Gi           csi-vsphere-vsc   snapcontent-ee26485f-499e-42db-85d4-d4b6f6d7b9bc   3m14s          11m

 

Or in the OpenShift console, at Storage > VolumeSnapshots.

 

You can then view the YAML of the volume snapshot and something like this should be returned. Notice in this example that the status shows the volume snapshot has been taken and there is a Volume Snapshot Content. Nice.

]$ oc get volumesnapshot my-volume-snapshot --namespace m-project --output yaml
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
  creationTimestamp: "2025-04-25T01:22:11Z"
  finalizers:
  - snapshot.storage.kubernetes.io/volumesnapshot-as-source-protection
  - snapshot.storage.kubernetes.io/volumesnapshot-bound-protection
  generation: 1
  name: my-pvc-volume-snapshot
  namespace: my-project
  resourceVersion: "505318001"
  uid: ee26485f-499e-42db-85d4-d4b6f6d7b9bc
spec:
  source:
    persistentVolumeClaimName: my-pvc
  volumeSnapshotClassName: csi-vsphere-vsc
status:
  boundVolumeSnapshotContentName: snapcontent-ee26485f-499e-42db-85d4-d4b6f6d7b9bc
  creationTime: "2025-04-25T01:29:59Z"
  readyToUse: true
  restoreSize: 1Gi

 

Or, in the OpenShift console, Storage > VolumeSnapshots if you select the Volume Snapshot and you see VolumeSnapshotContent then a snapshot of the volume has been taken.

 

 

The oc get VolumeSnapshotContent command can be used to list the Volume Snapshot Contents that have been taken.

]$ oc get volumesnapshotcontent --namespace my-project
NAME                                               READYTOUSE   RESTORESIZE   DELETIONPOLICY   DRIVER                   VOLUMESNAPSHOTCLASS   VOLUMESNAPSHOT       VOLUMESNAPSHOTNAMESPACE   AGE
snapcontent-d1e3b556-fb07-40b9-b032-976c9b5a84d7   true         1073741824    Delete           csi.vsphere.vmware.com   csi-vsphere-vsc       my-volume-snapshot   my-project                7m45s

 

Or in the OpenShift console at Storage > VolumeSnapshotContents.

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 4b5554 in the box below so that we can be sure you are a human.