bitnamicharts/cassandra

Verified Publisher

By VMware

Updated 11 months ago

Bitnami Helm chart for Apache Cassandra

Helm
Image
Internet of things
Databases & storage
1

1M+

bitnamicharts/cassandra repository overview

Bitnami Secure Images Helm chart for Apache Cassandra

Apache Cassandra is an open source distributed database management system designed to handle large amounts of data across many servers, providing high availability with no single point of failure.

Overview of Apache Cassandra

Trademarks: This software listing is packaged by Bitnami. The respective trademarks mentioned in the offering are owned by the respective companies, and use of them does not imply any affiliation or endorsement.

TL;DR

helm install my-release oci://REGISTRY_NAME/REPOSITORY_NAME/cassandra

Note: You need to substitute the placeholders REGISTRY_NAME and REPOSITORY_NAME with a reference to your Helm chart registry and repository.

Introduction

This chart bootstraps an Apache Cassandra deployment on a Kubernetes cluster using the Helm package manager.

Before you begin

  • Kubernetes 1.23+
  • Helm 3.8.0+
  • PV provisioner support in the underlying infrastructure

Installing the chart

To install the chart with the release name my-release:

helm install my-release oci://REGISTRY_NAME/REPOSITORY_NAME/cassandra

Note You need to substitute the placeholders REGISTRY_NAME and REPOSITORY_NAME with a reference to your Helm chart registry and repository. For example, in the case of Bitnami, you need to use REGISTRY_NAME=registry-1.docker.io and REPOSITORY_NAME=bitnamicharts.

These commands deploy one node with Apache Cassandra on the Kubernetes cluster in the default configuration. The Parameters section lists the parameters that can be configured during installation.

Note List all releases using helm list.

Configuration and installation details

This section covers resource requests, credentials, external secrets, TLS, and other options.

Resource requests and limits

Bitnami charts allow setting resource requests and limits for all containers inside the chart deployment. These are inside the resources value (check parameter table). Setting requests is essential for production workloads and these should be adapted to your specific use case.

To make this process easier, the chart contains the resourcesPreset values, which automatically sets the resources section according to different presets. Check these presets in the bitnami/common chart. However, in production workloads using resourcesPreset is discouraged as it may not fully adapt to your specific needs. Find more information on container resource management in the official Kubernetes documentation.

Update credentials

Bitnami charts configure credentials at first boot. Any further change in the secrets or credentials require manual intervention. Follow these instructions:

  • Update the user password following the upstream documentation
  • Update the password secret with the new values (replace the SECRET_NAME and PASSWORD placeholders)
kubectl create secret generic SECRET_NAME --from-literal=cassandra-password=PASSWORD --dry-run -o yaml | kubectl apply -f -
Using external secret providers

The Bitnami Cassandra chart supports using external secret providers like CSI plugins. With the value dbUser.useExternalSecretProvider, the chart will not render any reference to the authentication secret, avoiding any collision between the helm templates and the secret provider. This requires using extraEnvVars, extraVolumes, extraVolumeMounts, annotations or labels to add all the missing secret references, according to the plugin requirements.

In the following example, we will use the GKE Secret Manager to mount the authentication secrets:

dbUser:
  # We do not render the secret references
  useExternalSecretProvider: true

# We add the SecretProviderClass with the password stored in our Google Cloud Project
extraDeploy: 
  - apiVersion: secrets-store.csi.x-k8s.io/v1
    kind: SecretProviderClass
    metadata:
      name: cassandra-secret-provider
    spec:
      provider: gke
      parameters:
        secrets: |
          - resourceName: "projects/my-project/secrets/my-secret/versions/v1"
            path: "cassandra-password"

# Define the SecretProviderClass as an extra volume
extraVolumes:
  - name: external-cassandra-secret
    csi:
      driver: secrets-store-gke.csi.k8s.io
      readOnly: true
      volumeAttributes:
        secretProviderClass: cassandra-secret-provider

# Mount the volume in the cassandra container
extraVolumeMounts:
  - mountPath: "/var/secrets"
    name: external-cassandra-secret

# We specify the location of the password file
extraEnvVars:
  - name: CASSANDRA_PASSWORD_FILE
    value: "/var/secrets/cassandra-password"
Rolling vs immutable tags

It is strongly recommended to use immutable tags in a production environment. This ensures your deployment does not change automatically if the same tag is updated with a different image.

Bitnami will release a new chart updating its containers if a new version of the main container, significant changes, or critical vulnerabilities exist.

Prometheus metrics

This chart can be integrated with Prometheus by setting metrics.enabled to true. This will deploy a sidecar container with cassandra_exporter in all pods and will expose it using the Cassandra service. This service will have the necessary annotations to be automatically scraped by Prometheus.

Prometheus requirements

It is necessary to have a working installation of Prometheus or Prometheus Operator for the integration to work. Install the Bitnami Prometheus helm chart or the Bitnami Kube Prometheus helm chart to easily have a working Prometheus in your cluster.

Integration with Prometheus Operator

The chart can deploy ServiceMonitor objects for integration with Prometheus Operator installations. To do so, set the value metrics.serviceMonitor.enabled=true. Ensure that the Prometheus Operator CustomResourceDefinitions are installed in the cluster or it will fail with the following error:

no matches for kind "ServiceMonitor" in version "monitoring.coreos.com/v1"

Install the Bitnami Kube Prometheus helm chart for having the necessary CRDs and the Prometheus Operator.

Enable TLS

This chart supports TLS between client and server and between nodes, as explained in the following list:

  • For internode cluster encryption, set the tls.internodeEncryption chart parameter to a value different from none. Available values are all, dc or rack.
  • For client-server encryption, set the tls.clientEncryption chart parameter to true.

In both cases, it is also necessary to create a secret containing the keystore and truststore certificates and their corresponding protection passwords. Pass this secret to the chart using the tls.existingSecret parameter at deployment time, as in the following example:

tls.internodeEncryption=all
tls.clientEncryption=true
tls.existingSecret=my-existing-stores
tls.passwordsSecret=my-stores-password

Note The secret may be created in the standard way with the --from-file=./keystore, --from-file=./truststore, --from-literal=keystore-password=KEYSTORE_PASSWORD and --from-literal=truststore-password=TRUSTSTORE_PASSWORD options. This assumes that the stores are in the current working directory and the KEYSTORE_PASSWORD and TRUSTSTORE_PASSWORD placeholders are replaced with the correct keystore and truststore passwords respectively. Example:

kubectl create secret generic my-existing-stores --from-file=./keystore --from-file=./truststore
kubectl create secret generic my-stores-password --from-literal=keystore-password=KEYSTORE_PASSWORD --from-literal=truststore-password=TRUSTSTORE_PASSWORD

keystore and truststore files can be dynamically created from the certificates files. In this case a secret with the tls.crt, tls.key and ca.crt in PEM format is required. The following example shows how the secret can be created and assumes that all certificate files are in the working directory:

kubectl create secret tls my-certs --cert ./tls.crt --key ./tls.key
kubectl patch secret my-certs -p="{\"data\":{\"ca.crt\": \"$(cat ./ca.crt | base64 )\"}}"

To enable this feature tls.autoGenerated must be set and the new secret should be set in tls.certificateSecret:

tls.internodeEncryption=all
tls.clientEncryption=true
tls.autoGenerated=true
tls.certificatesSecret=my-certs
tls.passwordsSecret=my-stores-password
Initialize the database

The Apache Cassandra image supports the use of custom scripts to initialize a fresh instance. This may be done by creating a Kubernetes ConfigMap that includes the necessary .sh or .cql scripts and passing this ConfigMap to the chart using the initDBConfigMap parameter.

In case you require the whole cluster to be formed, you can enable an external init job that will wait for the cluster to be ready. Enable this by setting postInit.enabled=true and the necessary shell commands using the postInit.script value. In the script, the following environment variables are available:

  • CASSANDRA_USER: Admin username
  • CASSANDRA_PASSWORD: Admin password
  • CASSANDRA_KEYSTORE_LOCATION: keystore location (if tls.enabled=true)
  • CASSANDRA_TRUSTSTORE_LOCATION: truststore location (if tls.enabled=true)
  • CASSANDRA_SEEDER_HOST: First password seeder host.
  • CASSANDRA_CQL_PORT: CQL protocol port

The following example creates two new users:

postInit:
  enabled: true
  script: |
    cqlsh -u ${CASSANDRA_USER} -p "${CASSANDRA_PASSWORD}" --execute="CREATE ROLE IF NOT EXISTS newuser WITH SUPERUSER = false AND PASSWORD = 'newuser' AND LOGIN = true" $CASSANDRA_SEEDER_HOST $CASSANDRA_CQL_PORT
    cqlsh -u ${CASSANDRA_USER} -p "${CASSANDRA_PASSWORD}" --execute="GRANT CREATE ON ALL KEYSPACES TO newuser" $CASSANDRA_SEEDER_HOST $CASSANDRA_CQL_PORT
Use a custom configuration file

This chart also supports mounting custom configuration file(s) for Apache Cassandra. This is achieved by setting the existingConfiguration parameter with the name of a ConfigMap that includes the custom configuration file(s). Here is an example of deploying the chart with a custom configuration file stored in a ConfigMap named cassandra-configuration:

existingConfiguration=cassandra-configuration

Note This ConfigMap overrides other Apache Cassandra configuration variables set in the chart.

Backup and restore

See our detailed tutorial on backing up and restoring Bitnami Apache Cassandra deployments on Kubernetes.

Set pod affinity

This chart allows you to set custom pod affinity using the XXX.affinity parameter(s). Find more information about pod affinity in the Kubernetes documentation.

As an alternative, you can use the preset configurations for pod affinity, pod anti-affinity, and node affinity available at the bitnami/common chart. To do so, set the XXX.podAffinityPreset, XXX.podAntiAffinityPreset, or XXX.nodeAffinityPreset parameters.

FIPS parameters

The FIPS parameters only have effect if you are using images from the Bitnami Secure Images catalog.

For more information on this support, see the FIPS Compliance section.

Persistence

The Bitnami Apache Cassandra image stores the Apache Cassandra data at the /bitnami/cassandra path of the container.

Persistent Volume Claims are used to keep the data across deployments. This is known to work in GCE, AWS, and minikube. See the Parameters section to configure the PVC or to disable persistence.

If you encounter errors when working with persistent volumes, see our troubleshooting guide for persistent volumes.

Adjust permissions of persistent volume mount point

As the image runs as non-root by default, it is necessary to adjust the ownership of the persistent volume so that the container can write data into it. There are two approaches to achieve this:

  • Use Kubernetes SecurityContexts by setting the podSecurityContext.enabled and containerSecurityContext.enabled to true. This option is enabled by default in the chart. However, this feature does not work in all Kubernetes distributions.
  • Use an init container to change the ownership of the volume before mounting it in the final destination. Enable this container by setting the volumePermissions.enabled parameter to true.

Parameters

The following subsections list global, common, and component-specific parameters.

Global parameters
NameDescriptionValue
global.imageRegistryGlobal Docker image registry""
global.imagePullSecretsGlobal Docker registry secret names as an array[]
global.defaultStorageClassGlobal default StorageClass for Persistent Volume(s)""
global.defaultFipsDefault value for the FIPS configuration (allowed values: '', restricted, relaxed, off). Can be overridden by the 'fips' objectrestricted
global.security.allowInsecureImagesAllows skipping image verificationfalse
global.compatibility.openshift.adaptSecurityContextAdapt the securityContext sections of the deployment to make them compatible with Openshift restricted-v2 SCC: remove runAsUser, runAsGroup and fsGroup and let the platform use their allowed default IDs. Possible values: auto (apply if the detected running cluster is Openshift), force (perform the adaptation always), disabled (do not perform adaptation)auto
Common parameters
NameDescriptionValue
nameOverrideString to partially override common.names.fullname""
fullnameOverrideString to fully override common.names.fullname""
kubeVersionForce target Kubernetes version (using Helm capabilities if not set)""
commonLabelsLabels to add to all deployed objects (sub-charts are not considered){}
commonAnnotationsAnnotations to add to all deployed objects{}
clusterDomainKubernetes cluster domain namecluster.local
extraDeployArray of extra objects to deploy with the release[]
usePasswordFilesMount credentials as files instead of using environment variablestrue
diagnosticMode.enabledEnable diagnostic mode (all probes will be disabled and the command will be overridden)false
diagnosticMode.commandCommand to override all containers in the deployment["sleep"]
diagnosticMode.argsArgs to override all containers in the deployment["infinity"]
Cassandra parameters
NameDescriptionValue
image.registryCassandra image registryREGISTRY_NAME
image.repositoryCassandra image repositoryREPOSITORY_NAME/cassandra
image.digestCassandra image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag""
image.pullPolicyimage pull policyIfNotPresent
image.pullSecretsCassandra image pull secrets[]
image.debugEnable image debug modefalse
dbUser.userCassandra admin usercassandra
dbUser.forcePasswordForce the user to provide a nonfalse
dbUser.passwordPassword for dbUser.user. Randomly generated if empty""
dbUser.existingSecretUse an existing secret object for dbUser.user password (will ignore dbUser.password)""
dbUser.useExternalSecretProviderIf true, the rendered YAML will not create the secret references, instead, the user will use extraEnvVars, extraVolumes, extraVolumeMounts or other method. Use this for Secret Providers like GKE Secret Managerfalse
initDBObject with cql scripts. Useful for creating a keyspace and pre-populating data{}
initDBConfigMapConfigMap with cql scripts. Useful for creating a keyspace and pre-populating data

Note: the README for this chart is longer than the DockerHub length limit of 25000, so it has been trimmed. The full README can be found at https://techdocs.broadcom.com/us/en/vmware-tanzu/bitnami-secure-images/bitnami-secure-images/services/bsi-app-doc/apps-charts-cassandra-index.html

Tag summary

Content type

Image

Digest

sha256:e7562f5be

Size

7.8 kB

Last updated

11 months ago

docker pull bitnamicharts/cassandra:sha256-5b6770b28e75c51f2628bbb1d1906db1a88e96be2eadd360745c9f7543dc3a0f

This week's pulls

Pulls:

4,499

Jun 29 to Jul 5

Bitnami