I\’ve been running into customers using CockroachDB as their database a couple times in the past couple of weeks. I had heard of the technology on various podcasts, but hadn\’t used it myself yet. Given the coincidence of talking to multiple customers using CockroachDB, I thought I\’d give it a spin on AKS.
I\’ll start this blog with a short intro to CockroachDB, and then walk you through how to install it on AKS.
Intro to CockroachDB
My goal is to give a very high-level introduction. If you want to learn more, please refer to the architecture documents.
CockroachDB is an open-source, distributed SQL database developed by Cockroach Labs. It offers a PostgreSQL-compatible API to interact with the data. The main goals behind the project are to deliver a database that scalable, strongly consistent and can survive multiple forms of outages (disk, machine, rack and datacenter).
The database is scalable both from a storage as well as a compute perspective. You can add additional nodes to increase the capacity of the cluster. Queries against the database can be sent to any node, which will then distribute the query amongst the nodes.
CockroachDB implements strong consistency using the Raft consensus algorithm, which is also used by etcd.
Finally, the database provides survivability by giving the option to lock-free replicate data either within a same datacenter for low latency, or globally for higher failure tolerance. In terms of isolation of those replicas, you have the option to tune for either performance or correctness.
There are multiple ways to run CockroachDB:
- CockroachCloud: SaaS version of CockroachDB, which is (currently) available on either AWS or Google Cloud.
- Self-hosted: You can self-host CockRoachDB on either VMs or on Kubernetes. For the Kubernetes version, there\’s an operator available that makes setup easier. Optionally, you can also get enterprise support for self-hosted setups using CockroachDB Enterprise.
In this post, I\’ll be exploring a self-hosting option on Kubernetes on Azure. Why don\’t give that a try?
Setting up CockroachDB on AKS
For the purpose of this test, I\’m mainly following instructions from this documentation article. Please refer to the documentation for up to date instructions.
Let\’s start things out by creating a new AKS cluster and getting the credentials:
az group create -n cockroach -l westus2
az aks create -n cockroach -g cockroach \\
--node-vm-size Standard_D8ds_v4 --node-count 3 \\
--enable-managed-identity --generate-ssh-keys
az aks get-credentials -n cockroach -g cockroach
This will take about 5 minutes, and when that\’s done we can go ahead and install CockroachDB.
Leave a Reply