0
votes

I am trying to setup a redis cluster without persistence on a kubernetes cluster. Is there a way I can do that without persistence volume. I need auto recovery after pod reboot. is there an easy way to do that ?

Tried out updating node info with a script on startup which doesn't really work as the rebooted pod comes up with a new static private ip. fyi i have created a stateful set and a configmap referred here: https://github.com/rustudorcalin/deploying-redis-cluster and the empty dir setup for volumes. ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-volume-storage/

2
In order to recover, you need to store the states and data of your Redis pod somewhere it can persist even when your Redis pod dies. K8s provided StatefulSets and PersistentVolume for this. That may not be "easy", but if you don't use those, you will have to provide a similar mechanism without PersistentVolume which I suppose is going to be more complex.mOchi

2 Answers

0
votes

You cannot do this, the state of your redis is lots when a pod is restarted. Even with persistence storage is not so easy. You will need some kind of orchestration to manage and reconnect Redis.

0
votes

Do you mean actual cluster mode or just running Redis in general without persistence? This is what I usually use.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: ...
  namespace: ...
  labels:
    app.kubernetes.io/name: redis
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: redis
  template:
    metadata:
      labels:
        app.kubernetes.io/name: redis
    spec:
      containers:
      - name: default
        image: redis:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 6379
        args:
        - "--save"
        - ""
        - "--appendonly"
        - "no"