Sample Kubernetes Operator for Apache Cassandra Configuration Files
Sample manifest files are available in the Kubernetes Operator for Apache Cassandra GitHub repository.
In Quickstart for the Kubernetes Operator for Apache Cassandra, the kubectl commands applies these sample manifest files, as well as storage and datacenter configurations.
This reference reviews important portions of the Cassandra Operator configuration files.
Load the Cassandra Operator with kubectl
You can use kubectl to apply a manifest to your cluster.
Because the manifest installs a custom resource definition (CRD), the user running the kubectl apply command must have cluster-admin privileges.
The following example deploys the Cassandra Operator and any requisite resources, such as Role and RoleBinding, to the cass-operator namespace:
kubectl apply -f https://raw.githubusercontent.com/k8ssandra/cass-operator/v1.7.1/docs/user/cass-operator-manifests.yaml
Check that the Cassandra 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
Load the Cassandra Operator with Helm
Alternatively, you can use Helm to load the Cassandra Operator:
-
Create the destination namespace:
kubectl create namespace cass-operator-system -
Load the Cassandra Operator Helm chart:
helm install --namespace=cass-operator-system cass-operator ./charts/cass-operator-chart -
Optional: If needed, override any of 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: IfNotPresentIf you use
--set clusterWideInstall=true:-
roleNameandroleBindingNameare used forclusterRoleandclusterRoleBinding. -
The Cassandra Operator can administer the
CassandraDatacenterin all of the cluster’s namespaces. However, you must still specify--namespacebecause some Kubernetes resources for the Cassandra Operator require a namespace.
-
-
Create and apply a
StorageClassfor the Cassandra pods because Helm doesn’t install this for you.
Create and apply a StorageClass
Create an appropriate StorageClass to define the type of storage to use for Cassandra nodes in a cluster.
The following example defines a StorageClass that uses SSDs in a Google Kubernetes Engine (GKE):
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/k8ssandra/cass-operator/master/operator/k8s-flavors/gke/storage.yaml
Create and apply a CassandraDatacenter
The following example resource defines a Cassandra 3.11.7 datacenter with three nodes on one rack:
# 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
metadata:
name: dc1
spec:
clusterName: cluster1
serverType: cassandra
serverVersion: "3.11.7"
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/k8ssandra/cass-operator/v1.7.1/operator/example-cassdc-yaml/cassandra-3.11.x/example-cassdc-minimal.yaml
Verify status
Check the status of pods in the Cassandra cluster:
kubectl -n cass-operator get pods --selector cassandra.datastax.com/cluster=cluster1
Ideally, all pods should be fully READY with STATUS Running:
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 check the progress of bringing the Cassandra datacenter online, get the cassandraOperatorProgress field from the status sub-resource in CassandraDatacenter:
kubectl -n cass-operator get cassdc/dc1 -o "jsonpath={.status.cassandraOperatorProgress}"
|
|
If the output is Ready, then the Cassandra Operator has finished setting up the Cassandra datacenter.
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
Ideally, all nodes should report UN (up, normal):
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