apiVersion: v1
kind: Pod
metadata:
  name: consume
spec:
  containers:
    - name: consume
      image: mamachanko/wm:latest
      imagePullPolicy: Always
      command: [ "bash" ]
      args:
        - -euo
        - pipefail
        - -c
        - |
          while true; do
            wm flush \
              --db-connection-string="$WM_DB_CONNECTION_STRING" \
              --bootstrap-server="$WM_STREAM_BOOTSTRAP_SERVERS" \
              --topic="$WM_STREAM_TOPIC" \
              --consumer-group-id="$WM_STREAM_CONSUMER_GROUP_ID" \
              --ssl-cafile="$WM_STREAM_SSL_CA_FILE" \
              --ssl-certfile="$WM_STREAM_SSL_CERT_FILE" \
              --ssl-keyfile="$WM_STREAM_SSL_KEY_FILE"
            sleep 10
          done
      env:
        - name: WM_DB_CONNECTION_STRING
          valueFrom:
            secretKeyRef:
              name: wm-config
              key: wm.db.connection-string
        - name: WM_STREAM_BOOTSTRAP_SERVERS
          valueFrom:
            secretKeyRef:
              name: wm-config
              key: wm.stream.bootstrap-servers
        - name: WM_STREAM_TOPIC
          valueFrom:
            secretKeyRef:
              name: wm-config
              key: wm.stream.topic
        - name: WM_STREAM_CONSUMER_GROUP_ID
          valueFrom:
            secretKeyRef:
              name: wm-config
              key: wm.stream.consumer_group_id
        - name: WM_STREAM_SSL_CA_FILE
          value: "/var/secrets/wm.stream.ssl_ca_file"
        - name: WM_STREAM_SSL_CERT_FILE
          value: "/var/secrets/wm.stream.ssl_cert_file"
        - name: WM_STREAM_SSL_KEY_FILE
          value: "/var/secrets/wm.stream.ssl_key_file"
      volumeMounts:
        - mountPath: "/var/secrets"
          name: secrets-volume
          readOnly: true
  volumes:
    - name: secrets-volume
      secret:
        secretName: wm-config