DEV Community

Cover image for How to use the K8ssandra operator
Abhijith Ganesh
Abhijith Ganesh

Posted on

How to use the K8ssandra operator

What is K8ssandra?

It is the kubernetes cluster version of the Database Apache-Cassandra along with Stargate, Prometheus operators, it is a simple and quick method to setup a near-full stack of the database instance

Requisites:

  • 4 CPU cores
  • 8128 MB

Software Requirements:

  • Minikube
  • Helm (v3)

Installation

  • Install the Rancher Local path provisoner by running the command
    kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml

  • Add the lightweight K8ssandra chart running the following command
    helm repo add dokc https://dokc.github.io/Helm-Charts/

  • Check whether the repo was installed

helm repo list

It must show something like this:

NAME                    URL
cassandra               https://helm.k8ssandra.io/stable
traefik                 https://helm.traefik.io/traefik
minio                   https://helm.min.io
dok                     https://dokc.github.io/Helm-Charts/
Enter fullscreen mode Exit fullscreen mode

The chart now has been configured for installation, to install the K8ssandra Chart

You can run the k8ssandra configuration yaml with the chart

 cassandra:
  version: < Cassandra Version Number, preferred version = 4.0.1 >  
  cassandraLibDirVolume:
    storageClass: local-path
    size: 5Gi
  allowMultipleNodesPerWorker: true
  heap:
   size: 1G
   newGenSize: 1G
  resources:
    requests:
      cpu: 1000m
      memory: 2Gi
    limits:
      cpu: 1000m
      memory: 2Gi
  datacenters:
  - name: < Data Center Name >
    size: < Size >
    racks:
    - name: < Rack Name >

kube-prometheus-stack:
  grafana:
    adminUser: < Grafana Admin User >
    adminPassword: < Grafana Password >


stargate:
  enabled: < Boolean >
  replicas: 1
  heapMB: 256
  cpuReqMillicores: 200
  cpuLimMillicores: 1000

Enter fullscreen mode Exit fullscreen mode

To run this:
helm install <cluster_name> dok/k8s-lightweight -f <filename>.yaml

This will run your Kubernetes cluster, To check the pods that are running, you can run the kubectl get pods and it must be like this

NAME                                                   READY   STATUS    RESTARTS   AGE
prometheus-test-dep-kube-prometheus-s-prometheus-0     2/2     Running   0          2m43s
test-dep-cass-operator-6c75d6d684-vh2ts                1/1     Running   0          2m45s
test-dep-datacenter1-default-sts-0                     2/2     Running   0          2m28s
test-dep-datacenter1-stargate-699f64f646-w85kw         1/1     Running   0          2m45s
test-dep-grafana-57fd996d9-c58tf                       2/2     Running   0          2m45s
test-dep-kube-prometheus-s-operator-767fc8984c-9rlmj   1/1     Running   0          2m45s
Enter fullscreen mode Exit fullscreen mode

** The pods may take up to 4 minutes to setup, please be patient **

Once the pods are setup, you can run kubectl get services

NAME                                       TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                                                 AGE
kubernetes                                 ClusterIP   10.96.0.1        <none>        443/TCP                                                 144m
prometheus-operated                        ClusterIP   None             <none>        9090/TCP                                                33s
test-dep-dc-test-additional-seed-service   ClusterIP   None             <none>        <none>                                                  32s
test-dep-dc-test-all-pods-service          ClusterIP   None             <none>        9042/TCP,8080/TCP,9103/TCP                              32s
test-dep-dc-test-service                   ClusterIP   None             <none>        9042/TCP,9142/TCP,8080/TCP,9103/TCP,9160/TCP            33s
test-dep-dc-test-stargate-service          ClusterIP   10.96.125.32     <none>        8080/TCP,8081/TCP,8082/TCP,8084/TCP,8085/TCP,9042/TCP   35s
test-dep-grafana                           ClusterIP   10.106.69.131    <none>        80/TCP                                                  35s
test-dep-kube-prometheus-s-operator        ClusterIP   10.100.170.208   <none>        443/TCP                                                 35s
test-dep-kube-prometheus-s-prometheus      ClusterIP   10.109.19.63     <none>        9090/TCP                                                35s
test-dep-seed-service                      ClusterIP   None             <none>        <none>                                                  32s
Enter fullscreen mode Exit fullscreen mode

You can port-forward these services as per your requirement

Example: kubectl port-foward svc/test-dep-grafana 80

You can use the kube-forwarder tool to port-forward the services in your local machines

Top comments (0)