The Kubernetes Volume Snapshots concepts documentation mentions Volume Snapshots can be pre-provisioned;
A cluster administrator creates a number of VolumeSnapshotContents. They carry the details of the real volume snapshot on the storage system which is available for use by cluster users. They exist in the Kubernetes API and are available for consumption.
How is this done?
Some background: I'm trying to create k8s Volume Snapshots (VS) from EBS snapshots. I want to use the VS to restore a mongodb replicaset that is deployed using the Bitnami helm chart.
I've tried creating the VS without creating a VolumeSnapshotContents using this method:
- Create EBS snapshot.
- Create EBS volume from snapshot.
- Create Persistent Volume (PV) from EBS volume.
- Create Persistent Volume Claim (PVC) to bind to PV.
- Bind PVC to PV by creating pod with PVC.
- Create VolumeSnapshot (VS) from PVC.
The last step fails with this error:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning SnapshotContentCreationFailed 21s snapshot-controller Failed to create snapshot content with error cannot find CSI PersistentVolumeSource for volume mongo-with-data
This is because the PV created in step 3 has this as its Source:
Source:
Type: AWSElasticBlockStore (a Persistent Disk resource in AWS)
VolumeID: vol-049483f660a6a66cf
FSType:
Partition: 0
ReadOnly: false
while a PV created (behind the scenes) through the creation of a pod using a PVC has this Source
Source:
Type: CSI (a Container Storage Interface (CSI) volume source)
Driver: ebs.csi.aws.com
FSType: ext4
VolumeHandle: vol-05b14044113937bee
ReadOnly: false
VolumeAttributes: storage.kubernetes.io/csiProvisionerIdentity=1625656807749-8081-ebs.csi.aws.com
Both PVs have the same StorageClass.