DataStax News: Astra Streaming now GA with new built-in support for Kafka and RabbitMQ. Read the press release.
Introduction: Deploying a Sample Application with Cassandra in Kubernetes
Since Apache Cassandra™ is a powerful database that scales well and is always available, it’s ideal for cloud-native apps. If you want to do cloud-native, you want Kubernetes. However, configuring, installing, monitoring and managing Cassandra on Kubernetes can be challenging - this is where K8ssandra comes in. K8ssandra not only makes it easy to install Cassandra using Kubernetes, but K8ssandra also installs several other useful tools and services. This learning module introduces the components of a cloud-native application deployed with Cassandra in Kubernetes, including the components of the K8ssandra ecosystem.
What Does A Cloud-Native Cassandra Application Architecture Look Like?
Running a stateless cloud-native application is easy. You can scale the application for higher demand by adding independent instances. But, stateful applications are another matter because the database can become a bottleneck.
The first step toward scaling stateful cloud-native apps is to use a microservices architecture so that the components of the application can scale independently. Apache Cassandra™ is an ideal database for a scalable microservices architecture.
However, cloud-native apps have other considerations such as monitoring the health of the app, back-up and restore of app data and other maintenance and management tasks.
Here, we present an example cloud-native Cassandra app, the Spring Pet Clinic. Spring is a Java application framework and the PetClinic app is a reference app that demonstrates using the Spring framework. We’ll familiarize ourselves with each of the components of this app.
What Is Cloud-Native App Microservice Architecture?
Cloud-native application architectures divide the application into stateless and stateful components. The stateless components contain the business and UI logic. The stateful component is the database with microservices access; that is, services with an API such as REST or GraphQL.
Our example Pet Clinic app consists of a stateless front-end component and a single back-end microservice to the stateful database. We deploy both components using Kubernetes so that we can scale the number of instances when necessary. The backend app component provides a microservice API that reads and writes data to and from Cassandra.
How Can I Monitor A Cloud-Native App?
It is important to keep an eye on your cloud-native apps to make sure they have the right amount of compute and storage resources. Not enough resources and your app will not be responsive for your users. Too many resources and you end up paying more than you need to. Unless you have the right tools, trying to ascertain your app’s resource utilizations can be a lot of work.
Two tools that many Kubernetes cloud-native apps use are Prometheus and Grafana. The tools work in concert to capture, and then display, system metrics. Cloud-native apps provide endpoints that Prometheus “scrapes” on a regular basis. Then, you can view these metrics from dashboards in Grafana.
K8ssandra configures the Cassandra endpoints for prometheus along with dashboards in Grafana while connecting it all together for you.
How Do I Keep Cassandra Running In Kubernetes?
Cassandra is fault-tolerant. When a node within a Cassandra cluster fails, Cassandra can keep running, but at some point, somebody needs to restart the failed node. Kubernetes uses components known as operators to monitor and restart nodes within a service. Cassandra has a custom operator called Cass-operator, which knows specifically how to monitor and keep a Cassandra database cluster running. The Cass-operator is part of K8ssanrda, so when you deploy K8ssandra, you not only get a Cassandra database cluster, but you also get the Cass-operator to ensure your database keeps running.Next: What is Cassandra Repair and How Does it Work in Kubernetes?
What Is Cassandra Repair And How Does It Work In Kubernetes?
Cassandra's architecture is highly distributed and scalable due to data replication. Whenever you replicate data, it is possible for the replicas to be out of sync. Repair (an unfortunate name since nothing is really broken) is the process of making sure all data replicas are consistent.
Cassandra best-practices suggest that you run a repair process regularly (every ten days). There are some finer points on how to run this process, which we will not discuss here. But, there is a tool known as Reaper that takes care of this for you. And, as you have probably already guessed, Reaper is a standard part of K8ssandra.
How Do I Backup A Cassandra Database In Kubernetes?
Backing up and restoring a distributed database like Cassandra can be a bit tricky. Fortunately, there is a service called Medusa that takes care of a lot of the heavy lifting. Once again, K8ssandra installs Medusa as part of its Kubernetes Cassandra ecosystem.Next: How do I create Cassandra APIs?
How Do I Create Cassandra APIs?
If you're building cloud-native apps, you want APIs to access your data. Creating APIs is a tedious job that we would like to avoid. Stargate removes the tedium by creating the APIs for you!
Included as part of K8ssandra, Stargate provides APIs to Cassandra tables. You can securely access Cassandra tables using REST, GraphQL, JSON Document APIs and more with no work on your part.
Items related to Kubernetes