Example: Deploying Cassandra with a StatefulSet [page]deterministic
This tutorial shows you how to run [Apache Cassandra](https://cassandra.apache.org/) on Kubernetes. Cassandra, a database, needs persistent storage to provide data durability (application _state_). In this example, a custom Cassandra seed provider lets the database discover new Cassandra instances as they join the Cassandra cluster.
*StatefulSets* make it easier to deploy stateful applications into your Kubernetes cluster. For more information on the features used in this tutorial, see [StatefulSet](/docs/concepts/workloads/controllers/statefulset/).
Cassandra and Kubernetes both use the term _node_ to mean a member of a cluster. In this tutorial, the Pods that belong to the StatefulSet are Cassandra nodes and are members of the Cassandra cluster (called a _ring_). When those Pods run in your Kubernetes cluster, the Kubernetes control plane schedules those Pods onto Kubernetes .
When a Cassandra node starts, it uses a _seed list_ to bootstrap discovery of other nodes in the ring. This tutorial deploys a custom Cassandra seed provider that lets the database discover new Cassandra Pods as they appear inside your Kubernetes cluster.
##
* Create and validate a Cassandra headless [Service](#gloss:service). * Use a [StatefulSet](#gloss:StatefulSet) to create a Cassandra ring. * Validate the StatefulSet. * Modify the StatefulSet. * Delete the StatefulSet and its [Pods](#gloss:pod).
##
To complete this tutorial, you should already have a basic familiarity with [Pods](#gloss:pod), [Services](#gloss:service), and [StatefulSets](#gloss:StatefulSet).
### Additional Minikube setup instructions
[Minikube](https://minikube.sigs.k8s.io/docs/) defaults to 2048MB of memory and 2 CPU. Running Minikube with the default resource configuration results in insufficient resource errors during this tutorial. To avoid these errors, start Minikube with the following settings:
```shell minikube start --memory 5120 --cpus=4 ```
## Creating a headless Service for Cassandra {#creating-a-cassandra-headless-service}
In Kubernetes, a [Service](#gloss:service) describes a set of [Pods](#gloss:pod) that perform the same task.
The following Service is used for DNS lookups between Cassandra Pods and clients within your cluster:
Create a Service to track all Cassandra StatefulSet members from the `cassandra-service.yaml` file:
```shell kubectl apply -f https://k8s.io/examples/application/cassandra/cassandra-service.yaml ```
### Validating (optional) {#validating}
Get the Cassandra Service.
```shell kubectl get svc cassandra ```
The response is
``` NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE cassandra ClusterIP None <none> 9042/TCP 45s ```
If you don't see a Service named `cassandra`, that means creation failed. Read [Debug Services](/docs/tasks/debug/debug-application/debug-service/) for help troubleshooting common issues.
## Using a StatefulSet to create a Cassandra ring
The StatefulSet manifest, included below, creates a Cassandra ring that consists of three Pods.
This example uses the default provisioner for Minikube. Please update the following StatefulSet for the cloud you are working with.
Create the Cassandra StatefulSet from the `cassandra-statefulset.yaml` file:
```shell # Use this if you are able to apply cassandra-statefulset.yaml unmodified kubectl apply -f https://k8s.io/examples/application/cassandra/cassandra-statefulset.yaml ```
If you need to modify `cassandra-statefulset.yaml` to suit your cluster, download https://k8s.io/examples/application/cassandra/cassandra-statefulset.yaml and then apply that manifest, from the folder you saved the modified version into: ```shell # Use this if you needed to modify cassandra-statefulset.yaml locally kubectl apply -f cassandra-statefulset.yaml ```
## Validating the Cassandra StatefulSet
1. Get the Cassandra StatefulSet:
```shell kubectl get statefulset cassandra ```
The response should be similar to:
…(trimmed)