apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: spi-redis
spec:
  selector:
    matchLabels:
      app: solarperformanceinsight
      component: redis
  serviceName: spi-redis
  replicas: 1
  template:
    metadata:
      labels:
        app: solarperformanceinsight
        component: redis
    spec:
      volumes:
        - name: redis-cnf
          configMap:
            name: spi-redis
            items:
              - key: redis-cnf
                path: redis.conf
        - name: redis-acl
          secret:
            secretName: spi-redis
      containers:
        - name: redis
          image: redis:6.0.9
          command:
            - sh
            - -c
            - redis-server /conf/redis.conf
          env:
          - name: REDISCLI_AUTH
            valueFrom:
              secretKeyRef:
                key: password
                name: spi-redis
          - name: REDISCLI_USER
            valueFrom:
              secretKeyRef:
                key: user
                name: spi-redis
          ports:
            - containerPort: 6379
              name: redis
          volumeMounts:
            - name: redis-cnf
              mountPath: /conf
            - name: redis-acl
              mountPath: /redis
              readOnly: true
          readinessProbe:
            exec:
              command:
              - /bin/sh
              - -i
              - -c
              - redis-cli --user $REDISCLI_USER ping
            failureThreshold: 3
            initialDelaySeconds: 5
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 1
          resources:
            requests:
              memory: 128Mi
            limits:
              memory: 400Mi
