Time to Complete
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.
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.
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.
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.
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?
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.
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?
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.
Are you ready to try it out? See how to deploy the Spring Pet Clinic Example on Kubernetes.
Learn to build scalable cloud-native apps using Apache Cassandra and Kubernetes
This scenario introduces the components of a cloud-native application deployed with Cassandra in Kubernetes, including the components of the K8ssandra ecosystem.
In this scenario, we'll deploy the example Pet Clinic app on K8ssandra. Then we'll take a tour 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.
Let's get started!
Items related to Kubernetes