Sashi
Sashi

Reputation: 135

Redis deployment in Kubernetes

I am trying to run a Redis cluster on Kubernetes. I am not planning to persist any Redis data to the disk. Is it possible to run the Redis cluster as Kubernetes deployment and not as a stateful set?

Upvotes: 1

Views: 4154

Answers (2)

Harsh Manvar
Harsh Manvar

Reputation: 30083

yes it is possible to persist data in PVC with stateful sets, however in helm chart for HA redis cluster they are using stateful sets only :

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/redis
          args: ["--requirepass", "admin", "--appendonly", "yes", "--save", "900", "1", "--save", "30", "2"]
          ports:
            - containerPort: 6379
              name: redis
          resources:
            limits:
              cpu: .50
              memory: 1500Mi
            requests:
              cpu: .25
              memory: 1024Mi
          volumeMounts:
            - name: redis-volume
              mountPath: /data
  volumeClaimTemplates:
  - metadata:
      name: redis-volume
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 20Gi

Upvotes: 1

coderanger
coderanger

Reputation: 54181

Yes, though I would probably still use StatefulSet specifically for the features to ensure only one pod starts at a time.

Upvotes: 1

Related Questions