Skip to content

alokhom/cassandra-statefulset-to-k8ssandra-migration

Repository files navigation

StatefulSet cassandra migration to k8ssandra.

Problem statement

There is no documentation for cassandra migration from statefulset to k8ssandra. This repo helps to make those steps possible to migrate within kubernetes. This was tested successfully on GKE using Statefulset migration to k8ssandra operator.

Backup of StatefulSet cassandra required for a K8ssandra migration:

  • The procedure allows to migrate from Cassandra in a vanilla STS to K8ssandra
  • The backup will be used in case something goes wrong after the migration (although you could restore that backup to the K8ssandra cluster as well)

Toolkit used:

Steps:

  1. A prior cassandra sts must be runnign similar to https://kubernetes.io/docs/tutorials/stateful-application/cassandra/. For example when you run the command..
$ nodetool status
Datacenter: datacenter1
=====================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address        Load      Tokens  Owns (effective)  Host ID                               Rack
UN  172.31.4.217   10.2 GiB  16      100.0%            9a9b5e8f-c0c2-404d-95e1-372880e02c43  us-west-2c
UN  172.31.38.15   10.2 GiB  16      100.0%            1e6a9077-bb47-4584-83d5-8bed63512fd8  us-west-2b
UN  172.31.22.153  10.2 GiB  16      100.0%            d6488a81-be1c-4b07-9145-2aa32675282a  us-west-2a

Proceed with below steps if above is a success.

  1. Backup your statefulset cluster. ( see backup-statefulset directory)
  2. Restore test the medusa backup copy. ( see restore directory )
  3. Steps below for k8ssandra migration(it has some common things with the step 1, see the migration directory in the repo)
  4. Set the replicas for STS cluster to 0 and keep the PV for a the time till you are confident to delete them to save cost.
kubectl scale statefulsets <sts-cassandra-name> --replicas=0
  1. Schedule backup and restore on k8ssandra using medusa as mentioned here https://docs-v2.k8ssandra.io/tasks/backup-restore/

References:

https://k8ssandra.io/blog/tutorials/cassandra-database-migration-to-kubernetes-zero-downtime/ https://github.com/alokhom/alokhom.github.io/blob/master/_posts/2022-7-25-test.md

About

A helpful tutorial for cassandra statefulset to k8ssandra migration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published