Redis-stack kubernetes pass custom redis configurations

525 views Asked by At

I'm creating redis-stack helm chart for the pet project. I would like to know on how to pass custom redis configurations to kubenetes statefulset of redis-stack.

There are no mention of such configurations at the https://github.com/redis-stack/helm-redis-stack/tree/main/charts/redis-stack

With custom configurations on redis-stack, I would like to change default password, set policies etc.

Above link incudes below:

  • statefulset yaml
  • helm chart values.yaml files
  • Image used: redis/redis-stack
2

There are 2 answers

0
Michael Major On

You can create a secret in your K8 namespace and use it as an env variable for the redis-stack or redis-stack-server template (whichever one you are using). The redis stack will pick up a REDIS_ARGS environment variable on start-up and apply it as command line args. The secret should contain a key/value pair, with the key being something like redis-args and the value being the command line args you want to use for your instance.
For example, if you want to set a custom password, you would set the redis-args value as:

--requirepass <your password>

Then, update the template with the following under the containers section of the spec

    spec:
      ...
      containers:
      - name: ...
        ...
        env:
        - name: REDIS_ARGS
          valueFrom:
            secretKeyRef:
              name: redis-stack-server
              key: redis-args

Hope this helps.

0
Sipho Sikakane On

Hi I ran into the same problem, and I didn't want to use the REDIS_ARGS as an environment variable and use the entire configuration file as the REDIS_ARGS was growing to be large, I found putting it in the main directory of the container to work for me:

spec:
  volumes:
    - name: redis-data
      persistentVolumeClaim:
        claimName: pvc-redis-claim
    - name: redis-config
      configMap:
        name: redis-config
...
volumeMounts:
        - name: redis-data
          mountPath: /data   
        - name: redis-config
          mountPath: /redis-stack.conf
          subPath: redis-stack.conf

This took a while to find but it follows how they do it in the docker example here. I hope this helps someone.