A closer look: sample Cassandra Operator configuration files

A closer look at the sample YAML configuration files provided by Cass Operator.

This topic highlights key portions of the configuration files provided by Cass Operator. In the quick start examples of Get started with Cassandra Operator, the kubectl commands applied the sample YAML manifest, storage, and datacenter configurations. Read this topic for a review of the settings and more options. If you're satisfied with the pre-configured settings, you do not need to reapply the YAML described here to your Kubernetes cluster. The Cass Operator and Cassandra workload should be up and running.
Tip: If you haven't already, create a Kubernetes cluster. For a walkthrough of the steps – especially if you're new to Kubernetes – see the Google Kubernetes Engine (GKE) cloud example in this guide's topic, Create a Kubernetes cluster.

Load the operator

DataStax provides sample manifests for each Kubernetes version from 1.13 through 1.17. Apply the relevant manifest to your cluster. For example:
K8S_VER=v1.16
kubectl apply -f https://raw.githubusercontent.com/datastax/cass-operator/v1.3.0/docs/user/cass-operator-manifests-$K8S_VER.yaml
Note: Because the manifest installs a Custom Resource Definition (CRD), the user running the command needs cluster-admin privileges.
The command above 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:
kubectl -n cass-operator get pods --selector name=cass-operator
NAME                             READY   STATUS    RESTARTS   AGE
cass-operator-555577b9f8-zgx6j   1/1     Running   0          25h

Loading the operator via Helm (optional)

Optionally, you can use Helm to load the Cass Operator. First, create the destination namespace:
kubectl create namespace my-custom-namespace
Then load the operator. Example:
helm install --namespace=my-custom-namespace cass-operator ./charts/cass-operator-chart
Optionally, you can override the following default Helm values:
serviceAccountName: cass-operator
clusterRoleName: cass-operator-cluster-role
clusterRoleBindingName: cass-operator
roleName: cass-operator
roleBindingName: cass-operator
deploymentName: cass-operator
deploymentReplicas: 1
image: "datastax/cass-operator:1.3.0"
imagePullPolicy: IfNotPresent
Note: Helm does not install a storage-class for the Cassandra pods. For help with that requirement, see the next section.

Create and apply a StorageClass

Create an appropriate StorageClass, which will define the type of storage to use for Cassandra nodes in a cluster. For example, here is a StorageClass for using SSDs in GKE. This YAML is available at operator/deploy/k8s-flavors/gke/storage.yaml.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: server-storage
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-ssd
  replication-type: none
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Delete
Apply the StorageClass YAML:
kubectl apply -f https://raw.githubusercontent.com/datastax/cass-operator/v1.3.0/operator/k8s-flavors/gke/storage.yaml

Create and apply a CassandraDatacenter

The following resource defines a Cassandra 3.11.6 datacenter with three nodes on one rack. This YAML is available at operator/example-cassdc-yaml/cassandra-3.11.6/example-cassdc-minimal.yaml.
apiVersion: cassandra.datastax.com/v1beta1
kind: CassandraDatacenter
metadata:
  name: dc1
spec:
  clusterName: cluster1
  serverType: cassandra
  serverVersion: 3.11.6
  managementApiAuth:
    insecure: {}
  size: 3
  storageConfig:
    cassandraDataVolumeClaimSpec:
      storageClassName: server-storage
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 5Gi
  config:
    cassandra-yaml:
      authenticator: org.apache.cassandra.auth.PasswordAuthenticator
      authorizer: org.apache.cassandra.auth.CassandraAuthorizer
      role_manager: org.apache.cassandra.auth.CassandraRoleManager
    jvm-options:
      initial_heap_size: 800M
      max_heap_size: 800M
Apply the CassandraDatacenter YAML:
kubectl -n cass-operator apply -f https://raw.githubusercontent.com/datastax/cass-operator/v1.3.0/operator/example-cassdc-yaml/cassandra-3.11.6/example-cassdc-minimal.yaml

Verify status

To check the status of pods in the Cassandra cluster:
kubectl -n cass-operator get pods --selector cassandra.datastax.com/cluster=cluster1
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 
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}"
Ready
Note: cassdc and cassdcs are supported short forms of CassandraDatacenter.

A value of Ready, as shown above, means the operator has finished setting up the Cassandra datacenter.

You can also check the Cassandra cluster status using nodetool by invoking it on one of the pods in the cluster:
kubectl -n cass-operator exec -it -c cassandra cluster1-dc1-r1-sts-0 -- nodetool status
Datacenter: dc1
===============
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving/Stopped
--  Address         Load       Tokens       Owns (effective)  Host ID                               Rack
UN  10.233.105.125  224.82 KiB  1            65.4%             5e29b4c9-aa69-4d53-97f9-a3e26115e625  r1
UN  10.233.92.96    186.48 KiB  1            61.6%             b119eae5-2ff4-4b06-b20b-c492474e59a6  r1
UN  10.233.90.54    205.1 KiB   1            73.1%             0a96e814-dcf6-48b9-a2ca-663686c8a495  r1 

What's next?