Portworx is the cloud native storage company that enterprises depend on to reduce the cost and complexity of rapidly deploying containerized applications across multiple clouds and on-prem environments. With Portworx, you can manage any database or stateful service on any infrastructure using any container scheduler. You get a single data management layer for all of your stateful services, no matter where they run.
A popular Kubernetes persistent storage and Docker storage solution, Portworx is a clustered block storage solution and provides a Cloud-Native layer from which containerized stateful applications programmatically consume block, file and object storage services directly through the scheduler.
In this tutorial, you will learn how to deploy Cassandra to Kubernetes and use Portworx Volumes to provide HA capability:
- Use the Portworx Storage Class to create a PVC with 3 replicas of the data
- Use a simple YAML file to deploy Cassandra using this storage class
- How to validate data persistence by deleting the Cassandra pod
High Level Overview
First we will deploy Cassandra in a stateful set with only a single node (replicas=1) to show the basics of node failover. We will create some data, force Cassandra to flush the data to disk, and then failover the Cassandra pod and show how it comes back up with it's data intact.
Then, we're going to show how we can scale the cluster to 3 nodes and dynamically create volumes for each.
Other things you should know
To learn more about how why running Redis on Portworx is a great idea take a look at the following links:
- Guide to run [Cassandra in Docker] containers(https://portworx.com/use-case/cassandra-docker-container/)
- Guide to Kubernetes and Cassandra
- HA Cassandra on GKE
- HA Cassandrra on EKS
- HA Cassandra on AKS
- HA Cassandra on OpenShift
- Introduction to Portworx
- Customer Stories
- STORK open source project.
This scenario assumes you have already covered the following scenarios:
Cassandra Stateful Set on Portworx 2.6
Create Cassandra StorageClass
Before we deploy cassandra, we will need to create a Portworx volume (PVC) for Cassandra. In order to create PVCs, we need a StorageClass which defined the class of storage available to us.
Step: Create StorageClass
Take a look at the StorageClass definition for Cassandra:
cat cassandra-sc.yaml. Note that we define a replication factor of 2 to accelerate Cassandra node recovery and we also defined a group name for Cassandra so that we can take 3DSnapshots which will be consistent across the whole Cassandra cluster. In production environment which larger clusters you would also add the "fg=true" parameter to your StorageClass to ensure that Portworx places each Cassandra volume and their replica on separate nodes so that in case of node failure we never failover Kafka to a node where it is already running. To enable this feature with a 3 volume group and 2 replicas you need a minimum of 6 worker nodes.
The parameters are declarative policies for your storage volume. See here for a full list of supported parameters.
Create the storage class using:
kubectl create -f cassandra-sc.yaml
Now that we have the StorageClass created, let's deploy Cassandra!