Kubernetes Redis rejson Persistence data not saving

4/9/2019

I am using https://hub.docker.com/r/redislabs/rejson/

apiVersion: v1
kind: Service
metadata:
  name: redis
spec:
  ports:
    - port: 6379
      name: redis
  clusterIP: None
  selector:
    app: redis
---
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
  name: redis
spec:
  selector:
    matchLabels:
      app: redis  
  serviceName: redis
  replicas: 1
  template:
    metadata:
      labels:
        app: redis 
    spec:
      containers:
        - name: redis
          image: redislabs/rejson
          args: ["--requirepass", "pass", "--appendonly", "yes", "--save", "900", "1", "--save", "30", "2"]
          ports:
            - containerPort: 6379
              name: redis
          volumeMounts:
            - name: redis-volume
              mountPath: /data
  volumeClaimTemplates:
  - metadata:
      name: redis-volume
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 1Gi

I am passing arg to kubernetes config for persistense data store with "--appendonly", "yes"

if i am not passing arg it is running with

`redis-cli:6379 > JSON.SET foo . '"bar"'`
OK

if i pass arg to kubernetes config it is generating error and json module in redis not working

`redis-cli:6379 > JSON.SET foo . '"bar"'`
(error) ERR unknown command `JSON.SET`, with args beginning with: `foo`, `.`, `"bar"`,

I am following this : https://estl.tech/deploying-redis-with-persistence-on-google-kubernetes-engine-c1d60f70a043

-- Harsh Manvar
docker
google-cloud-platform
kubernetes
redis

1 Answer

4/9/2019

The redislabs/rejson image needs to have the loadmodule switch as a CMD argument as well - this should work:

...
      args: ["--requirepass", "pass", "--appendonly", "yes", "--save", "900", "1", "--save", "30", "2", "--loadmodule", "/usr/lib/redis/modules/rejson.so"]
...
-- Itamar Haber
Source: StackOverflow