Back to Charts

⚠️ Repo Archive Notice

incubator/cassandra/README.md

latest16.5 KB
Original Source

⚠️ Repo Archive Notice

As of Nov 13, 2020, charts in this repo will no longer be updated. For more information, see the Helm Charts Deprecation and Archive Notice, and Update.

Cassandra

A Cassandra Chart for Kubernetes

DEPRECATION NOTICE

This chart is deprecated and no longer supported.

Install Chart

To install the Cassandra Chart into your Kubernetes cluster (This Chart requires persistent volume by default, you may need to create a storage class before install chart. To create storage class, see Persist data section)

bash
helm install --namespace "cassandra" -n "cassandra" incubator/cassandra

After installation succeeds, you can get a status of Chart

bash
helm status "cassandra"

If you want to delete your Chart, use this command

bash
helm delete  --purge "cassandra"

Upgrading

To upgrade your Cassandra release, simply run

bash
helm upgrade "cassandra" incubator/cassandra

0.12.0

This version fixes https://github.com/helm/charts/issues/7803 by removing mutable labels in spec.VolumeClaimTemplate.metadata.labels so that it is upgradable.

Until this version, in order to upgrade, you have to delete the Cassandra StatefulSet before upgrading:

bash
$ kubectl delete statefulset --cascade=false my-cassandra-release

Persist data

You need to create StorageClass before able to persist data in persistent volume. To create a StorageClass on Google Cloud, run the following

bash
kubectl create -f sample/create-storage-gce.yaml

And set the following values in values.yaml

yaml
persistence:
  enabled: true

If you want to create a StorageClass on other platform, please see documentation here https://kubernetes.io/docs/user-guide/persistent-volumes/

When running a cluster without persistence, the termination of a pod will first initiate a decommissioning of that pod. Depending on the amount of data stored inside the cluster this may take a while. In order to complete a graceful termination, pods need to get more time for it. Set the following values in values.yaml:

yaml
podSettings:
  terminationGracePeriodSeconds: 1800

Install Chart with specific cluster size

By default, this Chart will create a cassandra with 3 nodes. If you want to change the cluster size during installation, you can use --set config.cluster_size={value} argument. Or edit values.yaml

For example: Set cluster size to 5

bash
helm install --namespace "cassandra" -n "cassandra" --set config.cluster_size=5 incubator/cassandra/

Install Chart with specific resource size

By default, this Chart will create a cassandra with CPU 2 vCPU and 4Gi of memory which is suitable for development environment. If you want to use this Chart for production, I would recommend to update the CPU to 4 vCPU and 16Gi. Also increase size of max_heap_size and heap_new_size. To update the settings, edit values.yaml

Install Chart with specific node

Sometime you may need to deploy your cassandra to specific nodes to allocate resources. You can use node selector by edit nodes.enabled=true in values.yaml For example, you have 6 vms in node pools and you want to deploy cassandra to node which labeled as cloud.google.com/gke-nodepool: pool-db

Set the following values in values.yaml

yaml
nodes:
  enabled: true
  selector:
    nodeSelector:
      cloud.google.com/gke-nodepool: pool-db

Configuration

The following table lists the configurable parameters of the Cassandra chart and their default values.

ParameterDescriptionDefault
image.repocassandra image repositorycassandra
image.tagcassandra image tag3.11.5
image.pullPolicyImage pull policyAlways if imageTag is latest, else IfNotPresent
image.pullSecretsImage pull secretsnil
config.cluster_domainThe name of the cluster domain.cluster.local
config.cluster_nameThe name of the cluster.cassandra
config.cluster_sizeThe number of nodes in the cluster.3
config.seed_sizeThe number of seed nodes used to bootstrap new clients joining the cluster.2
config.seedsThe comma-separated list of seed nodes.Automatically generated according to .Release.Name and config.seed_size
config.num_tokensInitdb Arguments256
config.dc_nameInitdb ArgumentsDC1
config.rack_nameInitdb ArgumentsRAC1
config.endpoint_snitchInitdb ArgumentsSimpleSnitch
config.max_heap_sizeInitdb Arguments2048M
config.heap_new_sizeInitdb Arguments512M
config.ports.cqlInitdb Arguments9042
config.ports.thriftInitdb Arguments9160
config.ports.agentThe port of the JVM Agent (if any)nil
config.start_rpcInitdb Argumentsfalse
configOverridesOverrides config files in /etc/cassandra dir{}
commandOverridesOverrides default docker command[]
argsOverridesOverrides default docker args[]
envCustom env variables{}
schedulerNameName of k8s scheduler (other than the default)nil
persistence.enabledUse a PVC to persist datatrue
persistence.storageClassStorage class of backing PVCnil (uses alpha storage class annotation)
persistence.accessModeUse volume as ReadOnly or ReadWriteReadWriteOnce
persistence.sizeSize of data volume10Gi
resourcesCPU/Memory resource requests/limitsMemory: 4Gi, CPU: 2
service.typek8s service type exposing ports, e.g. NodePortClusterIP
service.annotationsAnnotations to apply to cassandra service""
podManagementPolicypodManagementPolicy of the StatefulSetOrderedReady
podDisruptionBudgetPod distruption budget{}
podAnnotationspod annotations for the StatefulSet{}
updateStrategy.typeUpdateStrategy of the StatefulSetOnDelete
livenessProbe.initialDelaySecondsDelay before liveness probe is initiated90
livenessProbe.periodSecondsHow often to perform the probe30
livenessProbe.timeoutSecondsWhen the probe times out5
livenessProbe.successThresholdMinimum consecutive successes for the probe to be considered successful after having failed.1
livenessProbe.failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded.3
readinessProbe.initialDelaySecondsDelay before readiness probe is initiated90
readinessProbe.periodSecondsHow often to perform the probe30
readinessProbe.timeoutSecondsWhen the probe times out5
readinessProbe.successThresholdMinimum consecutive successes for the probe to be considered successful after having failed.1
readinessProbe.failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded.3
readinessProbe.addressAddress to use for checking node has joined the cluster and is ready.${POD_IP}
rbac.createSpecifies whether RBAC resources should be createdtrue
serviceAccount.createSpecifies whether a ServiceAccount should be createdtrue
serviceAccount.nameThe name of the ServiceAccount to use
backup.enabledEnable backup on chart installationfalse
backup.scheduleKeyspaces to backup, each with cron time
backup.annotationsBackup pod annotationsiam.amazonaws.com/role: cain
backup.image.repositoryBackup image repositorymaorfr/cain
backup.image.tagBackup image tag0.6.0
backup.extraArgsAdditional arguments for cain[]
backup.envBackup environment variablesAWS_REGION: us-east-1
backup.resourcesBackup CPU/Memory resource requests/limitsMemory: 1Gi, CPU: 1
backup.destinationDestination to store backup artifactss3://bucket/cassandra
backup.google.serviceAccountSecretSecret containing credentials if GCS is used as destination
exporter.enabledEnable Cassandra exporterfalse
exporter.servicemonitor.enabledEnable ServiceMonitor for exportertrue
exporter.servicemonitor.additionalLabelsAdditional labels for Service Monitor{}
exporter.image.repoExporter image repositorycriteord/cassandra_exporter
exporter.image.tagExporter image tag2.0.2
exporter.portExporter port5556
exporter.jvmOptsExporter additional JVM options
exporter.resourcesExporter CPU/Memory resource requests/limits{}
extraContainersSidecar containers for the pods[]
extraVolumesAdditional volumes for the pods[]
extraVolumeMountsExtra volume mounts for the pods[]
affinityKubernetes node affinity{}
tolerationsKubernetes node tolerations[]

Scale cassandra

When you want to change the cluster size of your cassandra, you can use the helm upgrade command.

bash
helm upgrade --set config.cluster_size=5 cassandra incubator/cassandra

Get cassandra status

You can get your cassandra cluster status by running the command

bash
kubectl exec -it --namespace cassandra $(kubectl get pods --namespace cassandra -l app=cassandra-cassandra -o jsonpath='{.items[0].metadata.name}') nodetool status

Output

bash
Datacenter: asia-east1
======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens       Owns (effective)  Host ID                               Rack
UN  10.8.1.11  108.45 KiB  256          66.1%             410cc9da-8993-4dc2-9026-1dd381874c54  a
UN  10.8.4.12  84.08 KiB  256          68.7%             96e159e1-ef94-406e-a0be-e58fbd32a830  c
UN  10.8.3.6   103.07 KiB  256          65.2%             1a42b953-8728-4139-b070-b855b8fff326  b

Benchmark

You can use cassandra-stress tool to run the benchmark on the cluster by the following command

bash
kubectl exec -it --namespace cassandra $(kubectl get pods --namespace cassandra -l app=cassandra-cassandra -o jsonpath='{.items[0].metadata.name}') cassandra-stress

Example of cassandra-stress argument

  • Run both read and write with ration 9:1
  • Operator total 1 million keys with uniform distribution
  • Use QUORUM for read/write
  • Generate 50 threads
  • Generate result in graph
  • Use NetworkTopologyStrategy with replica factor 2
bash
cassandra-stress mixed ratio\(write=1,read=9\) n=1000000 cl=QUORUM -pop dist=UNIFORM\(1..1000000\) -mode native cql3 -rate threads=50 -log file=~/mixed_autorate_r9w1_1M.log -graph file=test2.html title=test revision=test2 -schema "replication(strategy=NetworkTopologyStrategy, factor=2)"