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.volumeClaimTemplatesto the manifest - add
spec.template.spec.containers[].volumeMountsto use that volume claim - tell the
redis-serverprocess to use the path you specified forvolumeMounts- in the below example, you would specify
dir /redis-datain your config
- in the below example, you would specify
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