External storage with free Redis

Is it possible to store the AOF and RDB data on external storage system? Basicaclly my Redis cluster is deployed in a Kubernetes cluster and I need to ensure there is a durable backup of data for each shard. In case a master and its replica go down, there is another backup of the data from which the new master and its new replica could boot from.

Are you using Deployments or StatefulSets? I wouldn’t recommend Deployments because there are so many things that can go wrong with them with persistent storage, but if you use StatefulSets, persistence requires only 3 things:

  • add spec.volumeClaimTemplates to the manifest
  • add spec.template.spec.containers[].volumeMounts to use that volume claim
  • tell the redis-server process to use the path you specified for volumeMounts
    • in the below example, you would specify dir /redis-data in your config
apiVersion: apps/v1
kind: StatefulSet
metadata:
  # ...
spec:
  template:
    spec:
      containers:
      - name: server
        # other container config
        volumeMounts:
        - name: redis-data
          mountPath: /redis-data
  volumeClaimTemplates:
  - metadata:
      name: redis-data
    spec:
      accessModes: [ReadWriteOnce]
      # your Kubernetes provider should have docs about storage classes
      storageClassName: "your-storage-class"
      resources:
        requests:
          storage: 1Gi # Edit to the size you need
1 Like