Difficulty: Intermediate
Estimated Time: 20 minutes

Warning: Under Construction

Simplify your ops-life by using the Kubernetes Cassandra Operator to run your Cassandra cluster!

In the previous scenario in this course, you learned how to run Cassandra using Docker. Docker containers make replication of Cassandra nodes possible, but it could be a lot of work to deploy them in a large cluster. This is where Kubernetes and the Cassandra Operator come in.

In this scenario, we'll learn how to:

  • Create a Kubernetes cluster using KinD
  • Deploy an ingress controller in the Kubernetes cluster
  • Install the Kubernetes Cassandra operator
  • Create a single node Cassandra cluster managed by the operator
  • Deploy the example Pet Clinic app that uses Cassandra

Note: As we start to use Kubernetes, it is important to recognize that we are working with two types of clusters:

  • Kubernetes clusters - a set of machines called Kubernetes nodes
  • Cassandra clusters - a set of those Kubernetes pods that host and run the Cassandra software


Here's a diagram of what we will build.

Pet Clinic on Cass-op

Note: The Cassandra Operator is a Kubnernetes package that simplifies managing your Kubernetes Cassandra cluster in a couple of ways.

  1. The operator introduces higher level constructs such as datacenters that don't occur in native Kubernetes
  2. The operator monitors your Cassandra cluster to keep it running in a state you specify
If a Cassandra node were to fail, the Cassandra Operator would create a replacement node. Also, if you decide to change the number of nodes in your Cassandra cluster (either increasing or decreasing), the operator manages the change for you.
Read more about the Cassandra Operator here.
Kubernetes operators use two Kubernetes constructs:

  • Custom Resource Definitions (CRD) - these introduce higher level abstraction (e.g., datacenters)
  • Custom control-loop logic - introduces domain-specific logic for managing domain specific resources


You're going to love the Cassandra Operator!

In this scenario, we learned how to:

  • Create a Kubernetes cluster using KinD
  • Deploy an ingress controller in the Kubernetes cluster
  • Install the Kubernetes Cassandra operator
  • Create a single node Cassandra cluster managed by the operator
  • Deploy the example Pet Clinic app that uses Cassandra

We've only scratched the surface or the Cassandra Kubernetes Operator in this scenario. You can use the operator for so many other things.

Check out the docs here for more info.

Deploying and maintaining a Cassandra cluster never looked easier!

Managing Cassandra Clusters in Kubernetes Using Cass-Operator

Step 1 of 11

Create a Kubernetes Cluster

In this step we'll create a Kubernetes cluster consisting of the master node and some worker nodes. We'll use KinD to create the Kubernetes cluster, which we will name cassandra-kub-cluster.

Click the following to create the KinD cluster. You will see the command perform seven steps and it will take 30-60 seconds.

kind create cluster --name cassandra-kub-cluster --config kind-config.yaml
What is KinD?
KinD is development tool we are using to create a Kubernetes cluster running inside a Docker container. As you know, most people use Kubernetes to manage systems of Docker containers. So, KinD is a Docker container that runs Kubernetes to manage other Docker containers - it's a bit recursive.

We use KinD so we can create a many-node Kubernetes cluster on a single machine. KinD is great because it's relatively light-weight, easy to install and easy to use.

We've already installed KinD for you. For your reference, here are the commands we used to install KinD.

curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.7.0/kind-$(uname)-amd64 chmod +x ./kind mv ./kind /usr/local/bin/kind

If you are interested, feel free to inspect the kind-config.yaml file.
Open kind-config.yaml

In this file you see that we are creating four nodes: a single control-plane node and three worker nodes. Every Kubernetes cluster needs at least one control-plane node to manage the cluster. The worker nodes are where we deploy our Kubernetes resources. The other details in the file are specific to KinD. Read more here.

We use kubectl to interact with the Kubernetes cluster. Let's try it out by inspecting the cluster nodes. Click the following.

watch kubectl get nodes
What is kubectl?
kubectl is the command we use to interact with our Kubernetes cluster. It is a very versatile command with many sub-commands and options. Read more here.

Once all nodes are Ready, click the following to send a Ctrl-C to exit the watch loop.

^C

Here's what we have so far.

KinD Kubernetes Cluster

In the diagram, you see the control-plane node and the three worker nodes.

Woot! Now we have a Kubernetes cluster and we can talk to it using kubectl.