This website/page will be End-of-life (EOL) after 31 August 2024. We recommend you to visit OpenEBS Documentation for the latest Mayastor documentation (v2.6 and above).
Mayastor is now also referred to as OpenEBS Replicated PV Mayastor.
This documentation outlines the process of migrating application volumes from CStor to Mayastor. We will leverage Velero for backup and restoration, facilitating the transition from a CStor cluster to a Mayastor cluster. This example specifically focuses on a Google Kubernetes Engine (GKE) cluster.
Velero Support: Velero supports the backup and restoration of Kubernetes volumes attached to pods through File System Backup (FSB) or Pod Volume Backup. This process involves using modules from popular open-source backup tools like Restic (which we will utilize).
For cloud provider plugins, refer to the Velero Docs - Providers section.
Velero GKE Configuration (Prerequisites): You can find the prerequisites and configuration details for Velero in a Google Kubernetes Engine (GKE) environment on the GitHub here.
Object Storage Requirement: To store backups, Velero necessitates an object storage bucket. In our case, we utilize a Google Cloud Storage (GCS) bucket. Configuration details and setup can be found on the GitHub here.
Velero Basic Installation: For a step-by-step guide on the basic installation of Velero, refer to the Velero Docs - Basic Install section.
This website/page will be End-of-life (EOL) after 31 August 2024. We recommend you to visit OpenEBS Documentation for the latest Mayastor documentation (v2.6 and above).
Mayastor is now also referred to as OpenEBS Replicated PV Mayastor.
Cassandra is a popular NoSQL database used for handling large amounts of data with high availability and scalability. In Kubernetes environments, managing and restoring Cassandra backups efficiently is crucial. In this article, we'll walk you through the process of restoring a Cassandra database in a Kubernetes cluster using Velero, and we'll change the storage class to Mayastor for improved performance.
Before you begin, make sure you have the following:
Access to a Kubernetes cluster with Velero installed.
A backup of your Cassandra database created using Velero.
Mayastor configured in your Kubernetes environment.
Set up your Kubernetes cluster credentials for the target cluster where you want to restore your Cassandra database. Use the same values for the BUCKET-NAME and SECRET-FILENAME placeholders that you used during the initial Velero installation. This ensures that Velero has the correct credentials to access the previously saved backups. Use the gcloud command if you are using Google Kubernetes Engine (GKE) as shown below:
Install Velero with the necessary plugins, specifying your backup bucket, secret file, and uploader type. Make sure to replace the placeholders with your specific values:
Confirm that your Cassandra backup is available in Velero. This step ensures that there are no credentials or bucket mismatches:
Check the status of the BackupStorageLocation to ensure it's available:
Create a Velero restore request for your Cassandra backup:
Monitor the progress of the restore operation using the below commands. Velero initiates the restore process by creating an initialization container within the application pod. This container is responsible for restoring the volumes from the backup. As the restore operation proceeds, you can track its status, which typically transitions from in progress to Completed.
In this scenario, the storage class for the PVCs remains as cstor-csi-disk
since these PVCs were originally imported from a cStor volume.
Your storage class was originally set to cstor-csi-disk
because you imported this PVC from a cStor volume, the status might temporarily stay as In Progress and your PVC will be in Pending status.
Inspect the status of the PVCs in the cassandra namespace:
Create a backup of the Persistent Volume Claims (PVCs) and then modify their storage class to mayastor-single-replica
.
The statefulset for Cassandra will still have the cstor-csi-disk
storage class at this point. This will be addressed in the further steps.
Edit the PVC YAML to change the storage class to mayastor-single-replica
. You can use the provided example YAML snippet and apply it to your PVCs.
Delete the pending PVCs and apply the modified PVC YAML to recreate them with the new storage class:
Observe the Velero init container as it restores the volumes for the Cassandra pods. This process ensures that your data is correctly recovered.
Run this command to check the restore status:
Run this command to check if all the pods are running:
You can use the following command to access the Cassandra pods. This command establishes a connection to the Cassandra database running on pod cassandra-1
:
The query results should display the data you backed up from cStor. In your output, you're expecting to see the data you backed up.
After verifying the data, you can exit the Cassandra shell by typing exit
.
Before making changes to the Cassandra StatefulSet YAML, create a backup to preserve the existing configuration by running the following command:
You can modify the Cassandra StatefulSet YAML to change the storage class to mayastor-single-replica
. Here's the updated YAML:
Apply the modified YAML to make the changes take effect:
Delete the Cassandra StatefulSet while keeping the pods running without controller management:
Use the kubectl apply command to apply the modified StatefulSet YAML configuration file, ensuring you are in the correct namespace where your Cassandra deployment resides. Replace <path_to_your_yaml> with the actual path to your YAML file.
To check the status of the newly created StatefulSet, run:
To confirm that the pods are running and managed by the controller, run:
This website/page will be End-of-life (EOL) after 31 August 2024. We recommend you to visit OpenEBS Documentation for the latest Mayastor documentation (v2.6 and above).
Mayastor is now also referred to as OpenEBS Replicated PV Mayastor.
In the current setup, we have a CStor cluster serving as the source, with Cassandra running as a StatefulSet, utilizing CStor volumes.
To initiate Velero, execute the following command:
Verify the Velero namespace for Node Agent and Velero pods:
In this example, we create a new database with sample data in Cassandra, a distributed database.
The data is distributed across all replication instances.
Cassandra is a distributed wide-column store database running in clusters called rings. Each node in a Cassandra ring stores some data ranges and replicates others for scaling and fault tolerance. To back up Cassandra, we must back up all three volumes and restore them at the destination.
Velero offers two approaches for discovering pod volumes to back up using File System Backup (FSB):
Opt-in Approach: Annotate every pod containing a volume to be backed up with the volume's name.
Opt-out Approach: Back up all pod volumes using FSB, with the option to exclude specific volumes.
Opt-in:
In this case, we opt-in all Cassandra pods and volumes for backup:
To perform the backup, run the following command:
Check the backup status, run the following command: