0

I have statefulset redis cluster in kubernetes.
I want to import dump.rdb file which is taken othet redis to this redis cluster . what is the best way to import this dump file ?

1 Answers1

0

It may be ugly but can work

1- Create a configmap with your dump file in it ( don't know if the dump.rdb is a binary file or not, I assume this is not but if this is a binary file follow this: How can I store a binary file in a Kubernetes ConfigMap?), you can do this in an imperative manner for example with:

kubectl create configmap dump --from-file dump.rdb

2- Mount it like this in your statefulset:

...
        volumeMounts:
        - name: "dump"
          mountPath: "/DUMP_LOCATION/dump.rdb"
          subPath: "dump.rdb"
      volumes:
        - name: "dump"
          configMap:
            name: "dump"
...

3- Create, in the same way a configmap to mount the redis configuration file ( if not already done, if not you should).

4- In you configuration file, change to following parameters to tell redis to use the new location of the dump.rdb file you just mounted:

# path to the dump file
dbfilename dump.rdb

# The working directory (not a file) where DB will be written inside, with the filename specified
# above (dbfilename) configuration directive.
# 
dir /data/mydirectory/

After this restart your statefulset with the new configuration and it should be it, tell me if this worked

Bguess
  • 1,700
  • 1
  • 11
  • 24