Redis Save Migrate & Resume (SMR) on Kubernetes
Performing a save/migrate/resume of an in-cluster redis db.
Setup
Let's first set up a sample redis database on k8s. Create a namespace called cedana-examples
and install redis-example.yaml
, which can be found here: https://github.com/cedana/cedana-helm-charts/tree/main/examples.
Now let's port-forward the service on 127.0.0.1 and connect to the database:
Lets store some data in the db:
Listing all the pods in the cedana-examples
namespace using the /list
endpoint gives us all the information we need to do a checkpoint and restore.
Great! Now its time to checkpoint the container. Lets set the necessary environment variables before we proceed, which were present in the output of the /list
endpoint. The following variables should work on most default containerd clusters.
Checkpoint
Restore
Once this completes, we need a new pod to restore the redis checkpoint into - effectively acting as a sleeping pod that we morph into a restored redis pod. We do this to avoid colliding with Kubernetes' scheduling and state management, so the users have full control over when pods are being restored.
Then, performing a restore is as simple as another curl
call:
Finally connect to redis-cli once again to check if the new restored container has the previously set data:
Last updated
Was this helpful?