apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app.kubernetes.io/name: redis
  name: redis-sentinel-node
spec:
  replicas: 3
  selector:
    matchLabels:
      app.kubernetes.io/name: redis
      app.kubernetes.io/instance: redis-sentinel
  serviceName: redis-sentinel-headless
  template:
    metadata:
      labels:
        app.kubernetes.io/instance: redis-sentinel
        app.kubernetes.io/name: redis
    spec:
      # affinity:
      #   podAntiAffinity:
      #     preferredDuringSchedulingIgnoredDuringExecution:
      #     - podAffinityTerm:
      #         labelSelector:
      #           matchLabels:
      #             app.kubernetes.io/component: node
      #             app.kubernetes.io/instance: redis-sentinel
      #             app.kubernetes.io/name: redis
      #         namespaces:
      #         - default
      #         topologyKey: kubernetes.io/hostname
      #       weight: 1
      containers:
      - args:
        - -c
        - /opt/bitnami/scripts/start-scripts/start-sentinel.sh
        command:
        - /bin/bash
        env:
        - name: BITNAMI_DEBUG
          value: "false"
        - name: REDIS_PASSWORD
          valueFrom:
            secretKeyRef:
              key: redis-password
              name: redis-sentinel
        - name: REDIS_SENTINEL_TLS_ENABLED
          value: "no"
        - name: REDIS_SENTINEL_PORT
          value: "26379"
        image: docker.io/bitnami/redis-sentinel:6.2.6-debian-10-r95
        imagePullPolicy: IfNotPresent
        lifecycle:
          preStop:
            exec:
              command:
              - /bin/bash
              - -c
              - /opt/bitnami/scripts/start-scripts/prestop-sentinel.sh
        livenessProbe:
          exec:
            command:
            - sh
            - -c
            - /health/ping_sentinel.sh 5
          failureThreshold: 5
          initialDelaySeconds: 20
          periodSeconds: 5
          successThreshold: 1
          timeoutSeconds: 5
        name: sentinel
        ports:
        - containerPort: 26379
          name: redis-sentinel
          protocol: TCP
        readinessProbe:
          exec:
            command:
            - sh
            - -c
            - /health/ping_sentinel.sh 5
          failureThreshold: 5
          initialDelaySeconds: 20
          periodSeconds: 5
          successThreshold: 1
          timeoutSeconds: 1
        resources: {}
        securityContext:
          runAsUser: 1001
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /opt/bitnami/scripts/start-scripts
          name: start-scripts
        - mountPath: /health
          name: health
        - mountPath: /data
          name: redis-data
        - mountPath: /opt/bitnami/redis-sentinel/mounted-etc
          name: config
        - mountPath: /opt/bitnami/redis-sentinel/etc
          name: sentinel-tmp-conf
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext:
        fsGroup: 1001
      serviceAccount: redis-sentinel
      serviceAccountName: redis-sentinel
      terminationGracePeriodSeconds: 30
      volumes:
      - configMap:
          defaultMode: 493
          name: redis-sentinel-scripts
        name: start-scripts
      - configMap:
          defaultMode: 493
          name: redis-sentinel-health
        name: health
      - configMap:
          defaultMode: 420
          name: redis-sentinel-configuration
        name: config
      - emptyDir: {}
        name: sentinel-tmp-conf
      - emptyDir: {}
        name: redis-tmp-conf
      - emptyDir: {}
        name: tmp
  updateStrategy:
    rollingUpdate:
      partition: 0
    type: RollingUpdate


