Illustration Image

Cassandra.Link

The best knowledge base on Apache Cassandra®

Helping platform leaders, architects, engineers, and operators build scalable real time data platforms.

8/3/2018

Reading time:2 min

instaclustr/cassandra-operator

by John Doe

Cassandra operatorBuild Project status: pre-alphaMajor planned features have yet to be completed and API changes are currently planned, we reserve the right to address bugs and API changes in a backwards incompatible way before the project is declared stable. See upgrade guide for safe upgrade process.Currently user facing Cassandra cluster objects are created as Kubernetes Custom Resources, however, taking advantage of User Aggregated API Servers to improve reliability, validation and versioning may be undertaken. The use of Aggregated API should be minimally disruptive to existing users but may change what Kubernetes objects are created or how users deploy the operator.We expect to consider the Cassandra operator stable soon; backwards incompatible changes will not be made once the project reaches stability.OverviewThe Cassandra operator manages Cassandra clusters deployed to Kubernetes and automates tasks related to operating an Cassandra cluster.InstallCreate and destroyResizeRecover a node - TODOBackup and restore a cluster - TODORolling upgrade - TODOLimitationsThere are more spec examples on setting up clusters with backup, restore, and other configurations.Read Best Practices for more information on how to better use Cassandra operator.Read RBAC docs for how to setup RBAC rules for Cassandra operator if RBAC is in place.Read Developer Guide for setting up development environment if you want to contribute.See the Resources and Labels doc for an overview of the resources created by the Cassandra-operator.RequirementsKubernetes 1.8+Cassandra 3.11+Deploy Cassandra operatorSee instructions on how to install/uninstall Cassandra operator .Create and destroy an Cassandra cluster$ kubectl create -f example/common/test.yamlA 3 member Cassandra cluster will be created.$ kubectl get podsNAME READY STATUS RESTARTS AGEcassandra-operator7-5d58bc7874-t85dt 1/1 Running 0 18htest-dc-0 1/1 Running 0 1mtest-dc-1 1/1 Running 0 1mtest-dc-2 1/1 Running 0 1mSee client service for how to access Cassandra clusters created by operator.Destroy Cassandra cluster:$ kubectl delete -f example/common/test.yamlResize an Cassandra clusterCreate an Cassandra cluster, if you haven't already:$ kubectl apply -f example/common/test.yamlIn example/common/test.yaml the initial cluster size is 3.Modify the file and change replicas from 3 to 5.apiVersion: stable.instaclustr.com/v1kind: CassandraDataCentermetadata: name: test-dcspec: replicas: 5 image: "gcr.io/cassandra-operator/cassandra:latest"Apply the size change to the cluster CR:$ kubectl apply -f example/common/test.yamlThe Cassandra cluster will scale to 5 members (5 pods):$ kubectl get podsNAME READY STATUS RESTARTS AGEtest-dc-0 1/1 Running 0 1mtest-dc-1 1/1 Running 0 1mtest-dc-2 1/1 Running 0 1mtest-dc-3 1/1 Running 0 1mtest-dc-4 1/1 Running 0 1mSimilarly we can decrease the size of cluster from 5 back to 3 by changing the size field again and reapplying the change.apiVersion: stable.instaclustr.com/v1kind: CassandraDataCentermetadata: name: test-dcspec: replicas: 3 image: "gcr.io/cassandra-operator/cassandra:latest"Then apply the changes$ kubectl apply -f example/common/test.yamlLimitationsThis operator is currently a work in progress and breaking changes are landing in master all the time until we reach our initial release. Here be dragons!The operator does not currently manage backups, a command line backup utility is included, tested and built, but not yet managed by the operator.Do not use this in production.

Illustration Image

Cassandra operator

Build CircleCI

Project status: pre-alpha

Major planned features have yet to be completed and API changes are currently planned, we reserve the right to address bugs and API changes in a backwards incompatible way before the project is declared stable. See upgrade guide for safe upgrade process.

Currently user facing Cassandra cluster objects are created as Kubernetes Custom Resources, however, taking advantage of User Aggregated API Servers to improve reliability, validation and versioning may be undertaken. The use of Aggregated API should be minimally disruptive to existing users but may change what Kubernetes objects are created or how users deploy the operator.

We expect to consider the Cassandra operator stable soon; backwards incompatible changes will not be made once the project reaches stability.

Overview

The Cassandra operator manages Cassandra clusters deployed to Kubernetes and automates tasks related to operating an Cassandra cluster.

There are more spec examples on setting up clusters with backup, restore, and other configurations.

Read Best Practices for more information on how to better use Cassandra operator.

Read RBAC docs for how to setup RBAC rules for Cassandra operator if RBAC is in place.

Read Developer Guide for setting up development environment if you want to contribute.

See the Resources and Labels doc for an overview of the resources created by the Cassandra-operator.

Requirements

  • Kubernetes 1.8+
  • Cassandra 3.11+

Deploy Cassandra operator

See instructions on how to install/uninstall Cassandra operator .

Create and destroy an Cassandra cluster

$ kubectl create -f example/common/test.yaml

A 3 member Cassandra cluster will be created.

$ kubectl get pods
NAME                                    READY     STATUS    RESTARTS   AGE
cassandra-operator7-5d58bc7874-t85dt    1/1       Running   0          18h
test-dc-0                               1/1       Running   0          1m
test-dc-1                               1/1       Running   0          1m
test-dc-2                               1/1       Running   0          1m

See client service for how to access Cassandra clusters created by operator.

Destroy Cassandra cluster:

$ kubectl delete -f example/common/test.yaml

Resize an Cassandra cluster

Create an Cassandra cluster, if you haven't already:

$ kubectl apply -f example/common/test.yaml

In example/common/test.yaml the initial cluster size is 3. Modify the file and change replicas from 3 to 5.

apiVersion: stable.instaclustr.com/v1
kind: CassandraDataCenter
metadata:
  name: test-dc
spec:
  replicas: 5
  image: "gcr.io/cassandra-operator/cassandra:latest"

Apply the size change to the cluster CR:

$ kubectl apply -f example/common/test.yaml

The Cassandra cluster will scale to 5 members (5 pods):

$ kubectl get pods
NAME                            READY     STATUS    RESTARTS   AGE
test-dc-0                       1/1       Running   0          1m
test-dc-1                       1/1       Running   0          1m
test-dc-2                       1/1       Running   0          1m
test-dc-3                       1/1       Running   0          1m
test-dc-4                       1/1       Running   0          1m

Similarly we can decrease the size of cluster from 5 back to 3 by changing the size field again and reapplying the change.

apiVersion: stable.instaclustr.com/v1
kind: CassandraDataCenter
metadata:
  name: test-dc
spec:
  replicas: 3
  image: "gcr.io/cassandra-operator/cassandra:latest"

Then apply the changes

$ kubectl apply -f example/common/test.yaml

Limitations

  • This operator is currently a work in progress and breaking changes are landing in master all the time until we reach our initial release. Here be dragons!
  • The operator does not currently manage backups, a command line backup utility is included, tested and built, but not yet managed by the operator.
  • Do not use this in production.

Related Articles

migration
cassandra
kubernetes

How to Migrate Your Cassandra Database to Kubernetes with Zero Downtime

DataStax

11/15/2023

cassandra
kubernetes

Checkout Planet Cassandra

Claim Your Free Planet Cassandra Contributor T-shirt!

Make your contribution and score a FREE Planet Cassandra Contributor T-Shirt! 
We value our incredible Cassandra community, and we want to express our gratitude by sending an exclusive Planet Cassandra Contributor T-Shirt you can wear with pride.

Join Our Newsletter!

Sign up below to receive email updates and see what's going on with our company

Explore Related Topics

AllKafkaSparkScyllaSStableKubernetesApiGithubGraphQl

Explore Further

cassandra