Deploy a Sample Application with Cassandra in Kubernetes

Author: David Chung

This post is part of a Learning Series that shows you how to successfully run Apache Cassandra® in Kubernetes. Each workshop in this series will help you level up a new skill and introduce you to all the concepts you need to pass the K8ssandra Certification Exam.

With the adoption of Cassandra on Kubernetes skyrocketing, this Apache Cassandra Operations In Kubernetes Learning Series gives you the skills you need to keep up with the demand for cloud-native apps deployed on a highly scalable NoSQL database.

Plus, once you’ve completed the series, you can request a free voucher to take the K8ssandra certification exam. An official certification is the best way to gain a leg up in your career, command a higher salary, and begin mastering the powerful database behind leading enterprises including Apple, Instagram, Netflix, Sky, Spotify, TikTok, Uber, and more.

To prepare you for the exam, this first workshop introduces you to the technologies involved in deploying a cloud-native application with Cassandra in Kubernetes. In the process, you’ll learn how to use the following:

  • K8ssandra to run the sample app in Kubernetes
  • Prometheus to collect system metrics
  • Grafana to monitor the Cassandra database
  • Reaper to manage Cassandra data replica consistency
  • Stargate APIs to easily interact with Cassandra

At the end of this post, you can move onto the hands-on exercise where you’ll go through each step of the workshop within an interactive training environment.

Ready?

Understanding the technologies

To put you on the fast track, here’s a brief overview of the technologies covered in this workshop and what they’re used for.

K8ssandra

Apache Cassandra is a robust, easily-scalable database that’s ideal for cloud-native apps, which makes it a natural fit for Kubernetes — an orchestration platform for deploying and managing containerized systems in the cloud.

The problem is that Cassandra can be challenging to install, configure, monitor, and manage on Kubernetes without help. This is where a different kind of open-source project comes in.

K8ssandra provides a production-ready platform for running Apache Cassandra on Kubernetes. It also installs several other useful tools to create a developer-friendly ecosystem that simplifies (and automates) repairs, backups, and monitoring.

In the upcoming Katacoda scenario, you’ll deploy the example app in Kubernetes using K8ssandra to see just how easy it is. But first, let’s take a quick look at some of the tools K8ssandra offers to help you build scalable, cloud-native apps.

Helm

Helm is a package manager for Kubernetes that lets you install and update even the most complex Kubernetes apps. K8ssandra is Helm-based, and you can deploy all of its components with a single Helm command, saving you hours of sitting at your computer.

Figure 1. Diagram showing how Helm launches K8s clusters.

Prometheus

Prometheus is the software K8ssandra uses to collect useful metrics, monitor events in your Cassandra database, and issue alerts. Prometheus captures these metrics by “scraping” endpoints provided by the components within a Kubernetes cluster. To view these metrics, K8ssandra uses a nifty dashboard called Grafana, which we’ll look at next.​​

Figure 2. Diagram showing Prometheus’ modules and services.

Grafana

Grafana is a “visualization web application” that provides a user interface to display metrics. K8ssandra uses Grafana to pull metrics from Prometheus (using PromQL, the Prometheus query language) and present them in a dashboard. K8ssandra has already pre-configured some Grafana dashboards so you can easily monitor your Cassandra cluster.

Figure 3. Diagram showing how Grafana retrieves metrics from Prometheus.

Reaper

Managing Cassandra repairs comes with the territory. With data replication an essential part of Cassandra’s distributed architecture, every Cassandra cluster will need repairs to ensure all data replicas are consistent. This process, however, is notoriously tedious and difficult to do.

Reaper removes the headache by connecting to a Cassandra cluster, analyzing its health, and initiating (or scheduling) repairs. This lets you easily automate repairs at scale for Cassandra clusters running in Kubernetes, earning it a place within K8ssandra’s toolbox. ​​

Figure 4. Diagram showing a single Reaper instance handling multiple data centers.

Stargate

Stargate is an open-source gateway that sits between your app and your Cassandra database. In short, it shields you from the complexity of Cassandra and gives you a group of APIs to easily interact with your database, without having to learn a bunch of languages or build microservices. These APIs are:

  • REST to access your data using a familiar interface through RESTful APIs
  • GraphQL to query any Cassandra database using GraphQL types, queries, and mutations
  • Document APIs to save and search schemaless JSON documents in Cassandra
  • gRPC to serve a Google RPC (gRPC) API from any Cassandra database
Figure 5. Diagram showing how Stargate fits into the Kubernetes architecture.

K8ssandra helpfully includes Stargate in its Cassandra ecosystem, so you’ll get to try out some of Stargate’s APIs in the following Katacoda scenario.

Scenario: deploy a sample app on Kubernetes with K8ssandra

Now that you have the right concepts in mind, it’s time to put them to use. To help you practice using the technologies in this workshop (without breaking anything), we’ve set up an interactive training scenario in Katacoda.

This scenario will walk you through the components of a cloud-native application deployed with Cassandra in Kubernetes. The app you’ll be deploying is the Pet Clinic app, which is simply a reference app for the Java Spring framework that manages data for a pet clinic business.

This exercise is completely beginner-friendly, and in just 15 minutes, you’ll learn how to:

  • 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

Ready to give it a try? Scroll to the bottom of the Apache Cassandra on Kubernetes Learning Series page and click “Start Scenario.” Once you’ve completed the exercise (and aced the sneaky quiz at the end), you’ll be one step closer to your official K8ssandra certification!

Follow DataStax on Medium for exclusive posts on all things Pulsar, Cassandra, streaming, Kubernetes, and more. To join a buzzing community of developers from around the world and stay in the data loop, follow DataStaxDevs on Twitter and LinkedIn.

Resources

  1. Start Scenario: Deploy a Sample Application with Cassandra in Kubernetes
  2. Learning Series: Apache Cassandra Operations in Kubernetes
  3. K8ssandra — Apache Cassandra on Kubernetes
  4. Cassandra on Kubernetes | Datastax
  5. Stargate — the official data API for DataStax Astra DB
  6. DataStax Academy
  7. DataStax Certifications

--

--

--

We’re huge believers in modern, cloud native technologies like Kubernetes; we are making Cassandra ready for millions of developers through simple APIs; and we are committed to delivering the industry’s first and only open, multi-cloud serverless database: DataStax Astra DB.

Recommended from Medium

Tutorial: Continuous Integration with Xcode 9 and Fastlane

Advanced ChatOps with Microsoft Teams — Part 2 — Real world use cases

Async programming in R and Shiny

Everything you need to know about Cloud Computing and it’s future.

MongoDB Replica set, Oplog and other ghosts that haunt you.

Setup NGINX with Nodejs — PART 2

Templates In Django

Top 5 tools for remote work

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
DataStax

DataStax

DataStax is the company behind the massively scalable, highly available, cloud-native NoSQL data platform built on Apache Cassandra®.

More from Medium

How to Migrate Your Cassandra Database to Kubernetes with Zero Downtime

Kafka on GCP Cluster

Helm incubator kafka setup with SSL auth

Kafka Consumer Autoscaling with KEDA