After my previous post about Using HELM Chart to Deploying OpenEBS to an Kubernetes Cluster using Terraform already up, I wanted to test Snapshot and Clone of a cStor Volume in OpenEBS.
We are going to take the configuration that was set up in the previous post (I invite you to look at it if you did not follow it ) We had :
- 3 nodes Kubernetes cluster
- 2 nodes Attributes OpenEBS storage cluster installed and configured
- Storage Class defined : openebs-sc-student1
- PVC (pvc-mssqldata01-student1) used by a SQL Server instance.
In this post you will see :
- How to deploy OpenEBS with Terraform
- Creating a StoragePool
- Creating a Storage Class
- Provisioning a Persistent Volume Claim
- Deploying a SQL Server instance on an OpenEBS storage
Prerequisites
Before you get started, you’ll need to have these things:
- Kubernetes 1.13+ with RBAC enabled
- iSCSI PV support in the underlying infrastructure
- OpenEBS installed and configured
- a Storage Class created
- a PVC created
- a Microsoft SQL Server instance
Infra
Create volumes Snapshot Persistent Volume Claim (PVC)
Snapshots are typically useful for purposes like audits and reporting. Another use for snapshot backups is that multiple snapshots can be created for a database, and these can be taken at different points in time. This helps with period-over-period analyses.
It is important to understand that database snapshots are directly dependent on the source database. Therefore, snapshots can never substitute your regular backup and restore strategy. For instance, if an entire database is lost, it would mean its source files are inconsistent. If the source files are unavailable, snapshots cannot refer to them, and so, snapshot restoration would be impossible.
Definition of some terms used :
Snapshot: A storage snapshot is a set of reference markers for data at a particular point in time. A snapshot acts like a detailed table of contents, providing the user with accessible copies of data that they can roll back to.
VolumeSnapshot: A snapshot request object in kubernetes. When this object is created then the snapshot controller would act on the information and try to create a VolumeSnapshotData.
VolumeSnapshotData: It is a kubernetes object that represents an actual volume snapshot. It contains information about the snapshot e.g. the snapshot name mapped by the actual storage vendor, creation time etc.
Creating a cStor Volume Snapshot
The following steps will help you to create a snapshot of a cStor volume. For creating the snapshot, you need to create a YAML specification and provide the required PVC name into it. The only prerequisite check is to be performed is to ensure that there is no stale entries of snapshot and snapshot data before creating a new snapshot.
Copy the following YAML specification into a file called vol_snapshot_student1.yaml.
Run the following command to create the snapshot of the provided PVC.
The above command creates a snapshot of the cStor volume and two new CRDs. To list the snapshots, use the following command
Now we can create a Clone from the VolumeSnapshot
Cloning is the process of copying an online database onto another server. The copy is independent of the existing database and is preserved as a point-in-time snapshot.
You can use a cloned database for various purposes without putting a load on the production server or risking the integrity of production data. Some of these purposes include the following:
- Performing analytical queries
- Load testing or integration testing of your apps
- Data extraction for populating data warehouses
- Running experiments on the data
- Migration …..
- We will demonstrate the ability to clone directly from a PVC as declared in the dataSource.It’s also possible to create forks of - the SQL Server database to create even more sophisticated workflows.
It’s now possible to transform the data of the “test” deployment without disturbing the data of the “prod” deployment. This opens up the possibility to create advanced testing and development workflows that uses an exact representation of production data. Whether this dataset is a few bytes or a handful of terabytes, the operation will only take a few seconds to execute as the clones are not making any copies of the source data. We will create a Clone directly from an existing PVC without creating a snapshot.
The clone is a writable physical copy
To create a clone out of a snapshot is very simple. All you need to do is create a pvc manifest that refers to the volumesnapshot object.
Copy the following YAML specification into a file called pvc_mssqldata01_snap_student1.yaml.
Run the following command to create the new PVC (clone) from VolumeSnapshot.
show a PVC is created : pvc-mssqldata01-snap-student1
* Now we can create a new SQL Server deployment using PVC : pvc-mssqldata01-snap-student1*
For the deployment of the Microsoft SQL Server instance we will use the following YAML file: deploy-mssql-s-student1.yaml
Create a new MS SQL Server instance:
Check if your SQL Server instance works:
We have two Microsoft SQL Server instances running.
Get NodePort : TCP port binding SQL Server services
Check database WideWorldImporters on two Microsoft SQL Server
In first instance :
In second instance
We have two Microsoft SQL Server instances with exactly the same data, goal achieved .
Conclusion
The volume clone is similar to dynamic volume provisioning. The only difference is the fact that the clone volume is provisioned through snapshot provisioner instead of volume provisioner. The advantage of openebs is that. cStor snapshots are fast because they use Copy-On-Write. Inshort when we take snapshots we are not actually copying the volume anywhere, instead cStor internally leverages the zfs to save/record indexes. Thus, both actual volume and snapshot would refer to the same block of data unless one of them updates it. OpenEBS extends the benefits of software-defined storage to cloud native through the container attached storage approach. It represents a modern, contemporary way of dealing with storage in the context of microservices and cloud native applications.
Kubernetes is moving towards CSI compliant storage spec, we will see in a next post the use of the CSI Driver for OpenEBS.