kubernetesgoogle-cloud-platformcassandracass-operator

Temporarily stopping K8s and Cassandra cluster


I have created a Cassandra cluster on Kubernetes using cass-operator on gcp. It is for my personal experimentation. To avoid incurring cost, I want to stop the cluster when I am not using it and start it when I need it without losing data. Is there a way to do so? Would setting number of size to 0 in example-cassdc-minimal.yaml stop the compute resources without losing data? If I change the size to 3 again later, would the existing data be picked?

UPDATE changing the size in example-cass-dc-minimal.yaml doesn't work as I get error The CassandraDatacenter "dc1" is invalid: spec.size: Invalid value: 1: spec.size in body should be greater than or equal to 1


Solution

  • Assuming you have cluster cluster1 in namespace k8ssandra-operator with datacenter dc1, command stop and start the datacenter would be

    kubectl patch -n k8ssandra-operator cassandradatacenters.cassandra.datastax.com dc1 --type=merge -p '{"spec":{"stopped":true}}'

    and

    kubectl patch -n k8ssandra-operator cassandradatacenters.cassandra.datastax.com dc1 --type=merge -p '{"spec":{"stopped":true}}'