Score:0

Redis Stack Server - Cannot Change Data Dir (Docker/Kubernetes)

ar flag

I am trying to get redis up and running in a Kubernetes environment. I’ve done many tutorials, read the documentation, etc. etc. I need to have the .rdb file and the .aof file(s) saved in a Persistent Volume so that the data can be persisted across Pod (or container) failures/deletions/etc. I have a redis instance starting, and I’m trying to use a custom config file. All the pods get created and run fine and the save and appendonly variables in the custom config file are updated/correct (the others are the default values). However, neither the daemonize nor the dir variables are updated. They remain the default values no matter what I do.

Custom config file:

daemonize yes
cluster-enabled no
dir /redis/storage
port 6397
save 60 5
save 300 1
appendonly yes

I’ve tried using a config map to create the custom config file then using the spec.template.spec.containers.command/spec.template.spec.containers.args to copy the custom config file (named redis-stack.conf) to /etc/, where there’s a redis-stack.conf file, which does get overwritten with the data in the custom config file. After the copy command, I have redis-stack-server /etc/redis-stack.conf. When I do kubectl apply -f <filename>.conf, then get a bash shell for one of the created pods and do redis-cli CONFIG GET DIR it returns the default dir.

I’ve tried adding redis-cli CONFIG SET DIR <custom dir> at the end of the spec.template.spec.containers.command/spec.template.spec.containers.args string, but that didn’t work either. There are no errors in the logs and nothing but successful events.

I’ve searched the web, but the answers I’ve found that deal with a similar problem don’t solve my issue.

Any help is appreciated.

Score:0
ar flag

I figured this out. The only way I could get it to use a custom persistence directory was to add the directory as a command line argument when I started redis-stack-server in the spec.template.spec.containers.args (where spec.template.spec.containers.command is [“sh”, “-c”]). So spec.template.spec.container.args is redis-stack-server /path/to/custom-config.conf --dir /path/to/mounted/persistent-volume. This loads everything from the custom config file (except daemonize, which I think actually needs to be no in my case anyway) and also properly sets the custom persistence directory.

It’s amazing what taking a two week break from working on something can do for problem-solving. ;-)

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.