OpenEBS for CockroachDB
#
IntroductionCockroachDB is a cloud-native SQL database for building global, scalable cloud services that survive disasters. It is a distributed SQL database built on a transactional and strongly consistent key-value store. It scales horizontally; survives disk, machine, rack, and even data center failures with minimal latency disruption and no manual intervention; supports strongly consistent ACID transactions; and provides a familiar SQL API for structuring, manipulating, and querying data.
This guide explains the basic installation for CockroachDB operators on OpenEBS Local PV devices.
#
Deployment modelThe Local PV volume will be provisioned on a node where CockroachDB pods are getting scheduled and uses one of the matching unclaimed block devices for each of them, which will then use the entire block device for storing data. No other application can use this device. If users have limited block devices attached to some nodes, they can use nodeSelector
in the application YAML to provision applications on particular nodes where the available block device is present. The recommended configuration is to have at least three nodes and one unclaimed external disk to be attached per node.
#
Configuration workflow- Install OpenEBS
- Select OpenEBS storage engine
- Configure OpenEBS Local PV StorageClass
- Install CockroachDB Operator
- Accessing CockroachDB
#
Install OpenEBSIf OpenEBS is not installed in your K8s cluster, this can be done from here. If OpenEBS is already installed, go to the next step.
#
Select OpenEBS storage engineA storage engine is the data plane component of the IO path of a Persistent Volume. In CAS architecture, users can choose different data planes for different application workloads based on a configuration policy. OpenEBS provides different types of storage engines and you should choose the right engine that suits your application requirements and storage available on your Kubernetes nodes. For more information you can read here.
After OpenEBS installation, choose the OpenEBS storage engine as per your requirement.
Choose cStor, If you are looking for replicated storage features and other enterprise graded features such as volume expansion, backup and restore, etc.
Choose OpenEBS Local PV, If you are looking for direct-attached storage or low latency data write or if the application manages data replication.
In this document, we are deploying CockroachDB using OpenEBS Local PV.
#
Configure OpenEBS Local PV StorageClassDepending on the type of storage attached to your Kubernetes worker nodes, you can select from different flavors of Dynamic Local PV - Hostpath, Device, LVM, ZFS, or Rawfile. For more information, you can read here.
The Storage Class openebs-device
will be used to deploy CockroachDB in the Kubernetes cluster.
Note: Ensure that you have at least one disk with the required capacity added to the corresponding nodes before CockroachDB installation. In this example, we have added one 100GB disk to each node.
#
Install CockroachDB OperatorInstall the CRD using the following command.
Note: On GKE, additional RBAC policy of cluster-admin is required. Use the following command to create it.
You can obtain the Google cloud user account by using the following command
Deploy the cockroachdb operator using the following command
Check Operator deployment pod status
#
Deploying CockroachDB clusterDownload the cluster configuration file and make the necessary changes as per your requirement.
We will update the storage class to use
openebs-device
, as shown below. Please note that for the production environment, make necessary other changes as per your requirement.Sample
example.yaml
changesApply the cluster configuration file
#
Verify CockroachDB is up and runningGet the CockroachDB Pods, StatefulSet, Service, and PVC details. It should show that StatefulSet is deployed with 3 cockroach pods in a running state.
#
Accessing CockroachDBWe will be using the built-in sql-client for accessing and running some sql queries. Enter into one of the cockroachdb pods by using the exec command.
Run some basic SQL queries. Example command:
Create a database user with a password for accessing the database using web UI.
Create one more database, which will be used later for running benchmark load
#
Accessing the database's web interface.We will be using NodePort for accessing the service. In the production environment either use a load balancer or ingress services as per your requirement
Create a new node port service using the following YAML spec. The following sample spec is saved as
cockroachdb-public-node-port.yaml
.Get the service details
Verify that the cockroachDB Dashboard is accessible using web interface
Login credentials for the web UI Username:
roach
Password:Q7gc8rEdS
#
See Also:OpenEBS architecture OpenEBS use cases Local PV concepts Understanding NDM