apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis
spec:
  replicas: 9
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "9121"
        prometheus.io/scheme: "https"
      labels:
        app: redis
    spec:
      containers:
      - name: redis
        image: redis:6.2
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
        ports:
        - containerPort: 6379
        volumeMounts:
        - mountPath: /tls-data
          name: tls-volume
        command: ["redis-server"]
        args: ["--tls-port", "6379", "--port", "0", "--tls-cert-file", "/tls-data/redis.crt", "--tls-key-file", "/tls-data/redis.key", "--tls-ca-cert-file", "/tls-data/ca.crt", "--loglevel", "debug"]

      - name: redis-exporter
        image: oliver006/redis_exporter:v1.36.0
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
        ports:
        - containerPort: 9121
        volumeMounts:
        - mountPath: /tls-data
          name: tls-volume
        env:
        - name: REDIS_EXPORTER_DEBUG
          value: 'true'
        # Redis client
        - name: REDIS_ADDR
          value: 'rediss://localhost:6379'
        - name: REDIS_EXPORTER_TLS_CA_CERT_FILE
          value: '/tls-data/ca.crt'
        - name: REDIS_EXPORTER_TLS_CLIENT_KEY_FILE
          value: '/tls-data/exporter.key'
        - name: REDIS_EXPORTER_TLS_CLIENT_CERT_FILE
          value: '/tls-data/exporter.crt'
        # Metrics endpoint
        - name: REDIS_EXPORTER_TLS_SERVER_KEY_FILE
          value: '/tls-data/exporter.key'
        - name: REDIS_EXPORTER_TLS_SERVER_CERT_FILE
          value: '/tls-data/exporter.crt'

      volumes:
      - name: tls-volume
        hostPath:
          # directory location on host
          path: /tls-data
