---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: redis
  namespace: default
spec:
  serviceName: redis
  replicas: 3
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      labels:
        app: redis
      annotations:
        app: test-redis-statefulset
    spec:
      containers:
      - name: redis
        command: ["redis-server", "/etc/redis/redis.conf"]
        image: library/redis:3.2
        ports:
        - name: redis
          containerPort: 6379
        volumeMounts:
        - name: data
          mountPath: /data
        - name: conf
          mountPath: /etc/redis
        resources:
          requests:
            cpu: 100m
            memory: 256Mi
        readinessProbe:
          exec:
            command:
            - sh
            - -c
            - "/usr/local/bin/redis-cli -h $(hostname) ping"
          initialDelaySeconds: 15
          timeoutSeconds: 5
      volumes:
      - name: config-map
        configMap:
          name: redis
  volumeClaimTemplates:
  - metadata:
      name: data
      annotations:
        volume.alpha.kubernetes.io/storage-class: default
    spec:
      accessModes: ["ReadWriteOnce"]
      resources:
        requests:
          storage: 500Mi
  - metadata:
      name: conf
      annotations:
        volume.alpha.kubernetes.io/storage-class: default
    spec:
      accessModes: ["ReadWriteOnce"]
      resources:
        requests:
          storage: 10Mi
