1 What is K8ssandra
Cassandra is a very good open source distributed NoSQL database, adopted by many good large companies, with high availability, flexible scalability, good performance and other characteristics.
Due to Cassandra’s advantages, we often need to use Cassandra on cloud services, so we need to deploy Cassandra on K8s, which gives us K8ssandra. K8ssandra not only helps us to quickly and reliably deploy Cassandra on Kubernetes, but also provides many components such as monitoring, backup, synchronization, access, etc. All of these are indispensable for a production-ready product.
The component architecture of K8ssandra is shown below:
- Cass-operator: ensures the normal running of the cluster.
- Reaper: A synchronization tool to ensure consistency;
- Medusa: data backup tool, support S3, GCP Cloud Storage, etc.
- Stargate: Provides apis for data access;
- Prometheus+Grafana: A common monitoring component for cloud natives.
2 install K8ssandra
2.1 installation Kubenetes
How to quickly start a Kubernetes using Minikube on Ubuntu is described in detail in the article “Getting Started with Service Grid Istio – Detailed documentation of Kubernetes installing Istio and using it”. For better compatibility, we specify the version of Kubernetes as follows:
Minikube start - driver = none - kubernetes - version = v1.19.13Copy the code
Since we are using PVC, we create a StorageClass:
$ kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml
Copy the code
2.2 installation helm3
We need to use Helm to deploy K8ssandra. Download Helm3 as follows:
Download the installation packageThe curl - LO, https://get.helm.sh/helm-v3.7.0-linux-amd64.tar.gz# decompressionTar - ZXVF helm - v3.7.0 - Linux - amd64. Tar. GzMove to the bin directory
mv linux-amd64/helm /usr/local/bin/helm
Copy the code
Add Helm’s repository:
helm repo add k8ssandra https://helm.k8ssandra.io/stable
$ helm repo list
NAME URL
k8ssandra https://helm.k8ssandra.io/stable
traefik https://helm.traefik.io/traefik
Copy the code
Check out the K8ssandra package:
$HELM Search Repo K8ssandra NAME CHART VERSION APP VERSION DESCRIPTION K8SSandra/K8SSandra 1.3.1 Provisions and Provisions configures an instance of the en... K8ssandra /k8ssandra-common 0.28.4 Helper library containingfunctionsused by man... K8ssandra /k8ssandra-operator 0.31.0 1.0.0 Kubernetes operatorwhichhandles the provision... K8ssandra /backup 0.26.0 Creates a... K8ssandra /cass-operator 0.31.0 1.8.0 Kubernetes operatorwhichhandles the provision... K8ssandra/mouse + v + v + v + v + V + V + Vfor. K8ssandra/mouse + + + + + + + + + + + + + + + + + + + + + + + +for. K8ssandra /restore 0.27.1 Creates aRestore custom resource inst...Copy the code
We can install K8ssandra/K8ssandra.
2.3 Installing K8ssandra with Helm
The Helm is a Chart+Value management mode, we prepare a YAML file (k8ssandra-values.yaml) to put some variables:
cassandra:
version: "4.0.0"
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: dc1
size: 1
racks:
- name: default
kube-prometheus-stack:
grafana:
adminUser: admin
adminPassword: admin123
stargate:
enabled: true
replicas: 1
heapMB: 256
cpuReqMillicores: 200
cpuLimMillicores: 1000
Copy the code
Install K8ssandra:
$ helm install -f k8ssandra-values.yaml k8ssandra k8ssandra/k8ssandra
NAME: k8ssandra
LAST DEPLOYED: Thu Sep 30 21:20:49 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
Copy the code
Do some necessary checks as follows:
$ helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
k8ssandra default 1 2021-09-30 21:20:49.409672869 +0800 CST deployed k8ssandra-1.3.1
$ kubectl get cassandradatacenters
NAME AGE
dc1 4m34s
$ kubectl describe CassandraDataCenter dc1 | grep "Cassandra Operator Progress:"
Cassandra Operator Progress: Ready
Copy the code
Check Pod and Service:
Obtain the username and password of the K8ssandra superuser
$ kubectl get secret k8ssandra-superuser -o jsonpath="{.data.username}" | base64 --decode ; echo
k8ssandra-superuser
$ kubectl get secret k8ssandra-superuser -o jsonpath="{.data.password}" | base64 --decode ; echo
TNE5xOk45C1aQsj29qxw
Copy the code
2.4 Adding a Node
We to the high availability and capacity, creating more Cassandra Node, directly modifying k8ssandra – values. Yaml is as follows:
cassandra:
version: "4.0.0"
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: dc1
size: 3
racks:
- name: racks1
- name: racks2
- name: racks3
kube-prometheus-stack:
grafana:
adminUser: admin
adminPassword: admin123
stargate:
enabled: true
replicas: 1
heapMB: 256
cpuReqMillicores: 200
cpuLimMillicores: 1000
Copy the code
After modification, upgrade configuration:
$ helm upgrade -f k8ssandra-values.yaml k8ssandra k8ssandra/k8ssandra
Release "k8ssandra" has been upgraded. Happy Helming!
NAME: k8ssandra
LAST DEPLOYED: Fri Oct 1 00:40:08 2021
NAMESPACE: default
STATUS: deployed
REVISION: 2
Copy the code
Check out Kubernetes resources:
3 Viewing Monitoring
Let’s take a look at the exposed Grafana service:
kubectl expose deployment k8ssandra-grafana --type=NodePort --name=grafana-out
Copy the code
Locate port 30348 of the NodePort, visit http://external IP address :30348
Account: admin/admin123
The following interfaces provide good monitoring interfaces:
4 summarizes
K8ssandra is a really good open source project. I will show you how to use Cassandra in K8ssandra development later.
Please check the code: github.com/LarryDpk/pk…