Difficulty: Beginner
Estimated Time: 15 minutes

This scenario introduces the components of a cloud-native application deployed with Cassandra in Kubernetes, including the components of the K8ssandra ecosystem.

What is K8ssandra?
According to the K8ssandra website, K8ssandra provides a production-ready platform for running Apache Cassandra on Kubernetes. This includes automation for operational tasks such as repairs, backups, and monitoring. Read more here.

In this scenario, we will:

  • Install the K8ssandra ecosystem
  • Deploy the Pet Clinic app
  • Use Prometheus to collect system metrics
  • Use Grafana to monitor the Cassandra database
  • Use Reaper to manage Cassandra data replica consistency
  • Access Cassandra using Stargate APIs

We'll deploy the example Pet Clinic app on K8ssandra. Then we'll take a tour of the K8ssandra ecosystem.

Let's get started!

This scenario showed you how to run the example Reactive Spring Pet Clinic app in Kubernetes using K8ssandra.

In this scenario, we:

  • Installed the K8ssandra ecosystem
  • Deployed the Pet Clinic app
  • Used Prometheus to collect system metrics
  • Used Grafana to monitor the Cassandra database
  • Used Reaper to manage Cassandra data replica consistency
  • Access Cassandra using Stargate APIs

K8ssandra gives you all the tools you need to have a scalable, world-class, cloud-native app!

Introduction: Deploying a Sample Application with Cassandra in Kubernetes

Step 1 of 13

Deploy K8ssandra and the Pet Clinic app

In this step we'll install K8ssandra and deploy the example app.

Want to know what is going on in the terminal window? We are setting up a Kubernetes cluster for you. The cluster consists of an admin node and three worker nodes. We will run the entire cluster in a single container using something called kind.
What is kind?
kind is Kubernetes 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 lightweight, easy to install and easy to use.

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

Once the cluster is ready, you can launch K8ssandra using Helm by clicking the following.

# Deploy K8ssandra
helm install k8ssandra-cluster-a k8ssandra/k8ssandra \
  -f config-values.yaml
What is Helm?
Helm is a package manager (like apt or yum) for Kubernetes. Helm allows you to install and update Kubernetes applications. You will notice in the previous command, the sub-command is install followed what we will name the installed package and the chart used to specify the installation. A chart is a specification file we use to tell Helm how to do the installation. Helm downloads the charts from a Helm repo. We'll see more about this later in the course, but you can read more here.

Now, let's wait for the Cassandra to completely initialize. The following command will complete when the Cassandra database is ready (this may take a minute or two).

# Wait for Cassandra to initialize
kubectl wait \
  --for=condition=Ready cassandradatacenter/dc1 \
What is kubectl?
kubectl is the command you use to interact with your Kubernetes cluster. It is a very versatile command with many sub-commands and options. Read more here.

Once the previous command completes, you have a running Cassandra database inside the K8ssandra ecosystem. Let's launch the app using Kubernetes by clicking the following.

# Deploy the Pet Clinic app
kubectl apply -f petclinic.yaml
How does Kubernetes use the yaml files (like petclinic.yaml)?
The magic of Kubernetes is its declarative nature. You describe what you want your system to look like and Kubernetes figures out the how to make it so. The yaml files that you use in Kubernetes are called manifests and are the declarative description of the components within your Kubernetes cluster. We'll look into this petclinic.yaml file later in this course, but if you are curious, you can take a look at the file by clicking the following. cat petclinic.yaml

It may take another minute for the app to make the initial connection to Cassandra. The following commands will wait for a successful connection.

Please be patient as it takes a little while for the app to completely initialize and make the connection to the database.

# Waiting for the app pod to be ready
kubectl wait \
  --for=condition=Ready pod \
  --selector=app=petclinic-backend \

# Waiting for the app to connect to Cassandra
while [ $(curl localhost:80/petclinic/api/pettypes 2> /dev/null | wc -l) -gt 0 ];
    sleep 1

Excellent! we've deployed the PetClinic app with K8ssandra!