The backend of your application stack usually includes a database with an API. In this scenario, we'll build a Django REST server on top of Cassandra!
In this scenario, we'll learn how to:
- Create a Kubernetes cluster
- Run Cassandra using the Kubernetes Operator
- Deploy a REST service that talks to the Cassandra cluster
- Access the REST service from outside the Kubernetes cluster
This is gonna be sweeeeet!
Cassandra, Kubernetes and REST
Set up a Kubernetes Cluster
In this step, we'll create a Kubernetes cluster consisting of the master node, some worker nodes and an ingress.
NOTE: In this scenario, we are simulating a full Kubernetes cluster running a Cassandra cluster and a REST service all on a Katacoda VM! This is a significant load, so some of the later steps may take some time to complete. Please be patient.
KinD to create the Kubernetes cluster named cassandra-kub-cluster.
KinDis Kubernetes running inside a Docker container. As you know, most people use Kubernetes to manage systems of Docker containers. So,
KinDis a Docker container that runs Kubernetes to manage other Docker containers - it's a bit recursive.
KinDso we can create a many-node Kubernetes cluster on a single machine.
KinDis great because it's relatively light-weight, easy to install and easy to use.
We've already installed
KinDfor you. For your reference, here are the commands we used to install
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
kind create cluster --name cassandra-kub-cluster --config kind-config.yaml
NOTE: You can check out any of the configuration files in the editor on the right. To open a file just click on its name. But, be aware that changes to the file save automatically, so be careful when reviewing files not to make inadvertent changes.
Next, we'll add an ingress to the Kubernetes cluster. An ingress allows us to access the nodes in the cluster from outside the cluster. This command may take some time to complete.
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/kind/deploy.yaml echo "$(tput setaf 2)Waiting for ingress to fully deploy...$(tput sgr0)" kubectl wait --namespace ingress-nginx \ --for=condition=ready pod \ --selector=app.kubernetes.io/component=controller \ --timeout=200s
Your cluster should be up and running. Let's take a look.
kubectl cluster-info --context kind-cassandra-kub-cluster