A Closer Look: Sample Kubernetes Operator for Apache Cassandra Configuration Files

Load the operator

DataStax provides sample manifest YAML. Apply the manifest to your cluster.

For example:

kubectl apply -f https://raw.githubusercontent.com/k8ssandra/cass-operator/v1.7.1/docs/user/cass-operator-manifests.yaml

Because the manifest installs a Custom Resource Definition (CRD), the user running the command needs cluster-admin privileges.

The kubectl command deployed the operator, along with any requisite resources such as Role and RoleBinding, to the cass-operator namespace. To check whether the operator is ready and in a Running state, issue:

kubectl -n cass-operator get pods --selector name=cass-operator

Sample output:

NAME                             READY   STATUS    RESTARTS   AGE
cass-operator-555577b9f8-zgx6j   1/1     Running   0          25h

[Optional] Loading the operator via Helm

Optionally, you can use Helm to load the Kubernetes Operator for Apache Cassandra.

  1. Create the destination namespace:

    kubectl create namespace cass-operator-system
  2. Load the Kubernetes Operator for Apache Cassandra.

    helm install --namespace=cass-operator-system cass-operator ./charts/cass-operator-chart
  3. [Optional] You can override the following default Helm values:

    clusterWideInstall: false
    serviceAccountName: cass-operator
    clusterRoleName: cass-operator-cr
    clusterRoleBindingName: cass-operator-crb
    roleName: cass-operator
    roleBindingName: cass-operator
    webhookClusterRoleName: cass-operator-webhook
    webhookClusterRoleBindingName: cass-operator-webhook
    deploymentName: cass-operator
    deploymentReplicas: 1
    image: "datastax/cass-operator:1.7.1"
    imagePullPolicy: IfNotPresent

    If you set clusterWideInstall to true:

    • roleName and roleBindingName are used for clusterRole and clusterRoleBinding.

    • Kubernetes Operator for Apache Cassandra can administer the CassandraDatacenters in all namespaces of the Kubernetes (K8s) cluster. A namespace must still be provided because some of the Kubernetes resources for the Kubernetes Operator for Apache Cassandra require a namespace. For example:

    kubectl create namespace cass-operator-system
    helm install --set clusterWideInstall=true --namespace=cass-operator-system cass-operator ./charts/cass-operator-chart

    Helm does not install a storage-class for the Cassandra pods. For help with that requirement, see Create and apply a StorageClass.

Create and apply a StorageClass

Create an appropriate StorageClass to define the type of storage to use for Cassandra nodes in a cluster. For example, here is a StorageClass for using Solid State Drives (SSDs) in a Google Kubernetes Engine (GKE). This YAML file is available at storage.yaml.

apiVersion: storage.k8s.io/v1
kind: StorageClass
  name: server-storage
provisioner: kubernetes.io/gce-pd
  type: pd-ssd
  replication-type: none
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Delete

Apply the StorageClass YAML:

kubectl apply -f https://raw.githubusercontent.com/k8ssandra/cass-operator/master/operator/k8s-flavors/gke/storage.yaml

Create and apply a CassandraDatacenter

The following resource defines a Cassandra 3.11.7 datacenter with three nodes on one rack. This YAML is available at example-cassdc-minimal.yaml.

# Sized to work on 3 k8s workers nodes with 1 core / 4 GB RAM
# See neighboring example-cassdc-full.yaml for docs for each parameter
apiVersion: cassandra.datastax.com/v1beta1
kind: CassandraDatacenter
  name: dc1
  clusterName: cluster1
  serverType: cassandra
  serverVersion: "3.11.7"
    insecure: {}
  size: 3
      storageClassName: server-storage
        - ReadWriteOnce
          storage: 5Gi
      authenticator: org.apache.cassandra.auth.PasswordAuthenticator
      authorizer: org.apache.cassandra.auth.CassandraAuthorizer
      role_manager: org.apache.cassandra.auth.CassandraRoleManager
      initial_heap_size: "800M"
      max_heap_size: "800M"

Apply the CassandraDatacenter YAML:

kubectl -n cass-operator apply -f https://raw.githubusercontent.com/k8ssandra/cass-operator/v1.7.1/operator/example-cassdc-yaml/cassandra-3.11.x/example-cassdc-minimal.yaml

Verify status

  1. To check the status of pods in the Cassandra cluster:

    kubectl -n cass-operator get pods --selector cassandra.datastax.com/cluster=cluster1

    Sample output:

    NAME                    READY   STATUS    RESTARTS   AGE
    cluster1-dc1-r1-sts-0   2/2     Running   0          26h
    cluster1-dc1-r1-sts-1   2/2     Running   0          26h
    cluster1-dc1-r1-sts-2   2/2     Running   0          26h
  2. To see the current progress of bringing the Cassandra datacenter online, check the cassandraOperatorProgress field of the CassandraDatacenter’s status sub-resource:

    kubectl -n cass-operator get cassdc/dc1 -o "jsonpath={.status.cassandraOperatorProgress}"

    Sample output:


    cassdc and cassdcs are supported short forms of CassandraDatacenter.

    A returned value of Ready indicates that the operator has finished setting up the Cassandra datacenter.

  3. You can also check the Cassandra cluster status by invoking nodetool on one of the pods in the cluster:

    kubectl -n cass-operator exec -it -c cassandra cluster1-dc1-r1-sts-0 -- nodetool status

    Sample output:

    Datacenter: dc1
    |/ State=Normal/Leaving/Joining/Moving/Stopped
    --  Address         Load       Tokens       Owns (effective)  Host ID                               Rack
    UN  224.82 KiB  1            65.4%             5e29b4c9-aa69-4d53-97f9-a3e26115e625  r1
    UN    186.48 KiB  1            61.6%             b119eae5-2ff4-4b06-b20b-c492474e59a6  r1
    UN    205.1 KiB   1            73.1%             0a96e814-dcf6-48b9-a2ca-663686c8a495  r1

What’s next?

Review options within key sections of the configuration YAML files.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com