Deploy Cassandra Cluster on Kubernetes with K8ssandra
Happy devSecOps
Background
In this post I’m gonna discuss about deploying Cassandra
cluster on Kubernetes
with using K8ssandra
. All the deployments which related to this post available in gitlab. Please clone the repo and continue the post.
About K8ssandra
K8ssandra is an open-source production-ready distribution of Apache Cassandra for Kubernetes. It uses Kubernetes Operator to manage Cassandra clusters in Kubernetes. Additionally it includes packages/tools for automation of Cassandra operational tasks such as repairs
, backups
, and monitoring
. Following are the main packages/tools includes in K8ssandra. K8ssandra assembles these tools and delivered as a collection of Helm
charts. That is the main difference between other Kubernetes Cassandra Operators(Cass-Operator
, CassKop
) and K8ssandra.
Cass-Operator
— The Kubernetes Operator to manage Cassandra database cluster on Kubernetes. It’s at the heart of K8ssandra.Cassandra Reaper
— Automatic Cassandra repair management tool.Cassandra Medusa
— Cassandra Backup and restore tool that works with different storage options.Prometheus
—Tool for collecting and visualizing metrics in the cloud-native container world.Grafana
— Data/matrix visualization tool which capable for making dashboards on top of Prometheus & Graphite.Metric Collector
— Built oncollectd
, it can work with Prometheus and Grafana or other systems.Traefik
— Ingress management/Proxy for containers and Kubernetes.- Stargate — Open-source data gateway providing common API interfaces for backend databases(e.g Cassandra).
Setup Kubernets Cluster
I have installed K8ssandra in local environment with K3d
based Kubernetes cluster(K3d run Kubernetes cluster on Docker). K8ssandra currently support till Kubernets v1.21.1
. So I have installed Kubernetes cluster below to this version(v1.20.12
). Following is the way to setup the Kubernetes cluster with K3d.
Deploy K8ssandra
Following is the configuration file to deploy single node Cassandra cluster with K8ssandra. This configuration need to inject when deploying the Helm chart.
The deployment of K8ssandra can be done with Helm chart as below. Then Helm chart will install all the above mentioned tools as Kubernetes pods and expose the Kubernetes services for them.
Connect to Cassandra
First we need to find the K8ssandra superuser username and password in order to access Cassandra utilities and do things like generate a Stargate access token.
K8ssandra expose Cassandra APIs to outside via k8ssandra-dc1-stargate-service
. Basically the service exposes 8080/TCP: GraphQL interface
, 8081/TCP: REST authorization service
, 8082/TCP: REST interface, 9042/TCP: CQL service
. Following is the way to connect to Cassandra with nodetool
and cqlsh
.
Connect to Prometheus
K8ssandra expose Prometheus APIs via k8ssandra-kube-prometheus-prometheus
service. It export 9090/TCP
port. We can port forward this port to the outside the cluster and connect to the Prometheus web.
Connect to Grafana
K8ssandra expose Grafana APIs via k8ssandra-grafana
service. It export 80/TCP
port. We can port forward this port to the outside the cluster and connect to the Grafana web dashboards. admin
/admin123
are the username/password of Grafana dashboard. These admin credentials are defined in the k8ssandra.yaml
config file.
Connect to Reaper
K8ssandra expose Reaper APIs via k8ssandra-reaper-reaper-service
. It export 8080/TCP
port. We can port forward this port to the outside the cluster and connect to the Reaper web.
Reference
- https://www.datastax.com/learn/apache-cassandra-operations-in-kubernetes/introduction
- https://blog.anant.us/what-is-k8ssandra/
- https://www.datastax.com/blog/2021/04/kubernetes-data-simplicity-getting-started-k8ssandra
- https://medium.com/flant-com/running-cassandra-in-kubernetes-challenges-and-solutions-9082045a7d93
- https://medium.com/building-the-open-data-stack/deploying-to-multiple-kubernetes-clusters-with-the-k8ssandra-operator-f7562bee1841