apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: redis-cluster
spec:
  selector:
    matchLabels:
      app: redis-cluster
  replicas: 6
  serviceName: redis-cluster-service
  template:
    metadata:
      labels:
        app: redis-cluster
    spec:
      containers:
        - name: redis
          image: redis:5.0.1-alpine
          command: ["/conf/update-node.sh", "redis-server", "/conf/redis.conf"]
          env:
          - name: POD_IP
            valueFrom:
              fieldRef:
                fieldPath: 'status.podIP'
          ports:
            - containerPort: 6379
              name: client
            - name: gossip
              containerPort: 16379
          volumeMounts:
            - name: conf
              mountPath: /conf
              readOnly: false
            - name: data
              mountPath: /data
      volumes:
      - name: conf
        configMap:
          name: redis-cluster-configmap
          defaultMode: 0755
  volumeClaimTemplates:
    - metadata:
        name: data
      spec:
        accessModes: [ "ReadWriteOnce" ]
        resources:
          requests:
            storage: 1Gi