#  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
#  Licensed under the Apache License, Version 2.0 (the "License").
#  You may not use this file except in compliance with the License.
#  A copy of the License is located at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  or in the "license" file accompanying this file. This file is distributed
#  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
#  express or implied. See the License for the specific language governing
#  permissions and limitations under the License.
apiVersion: batch/v1
kind: Job
metadata:
  name: fetcher-it
spec:
  template:
    spec:
      serviceAccountName: fetcher-dispatcher
      containers:
        - name: it
          image: benchmarkai/fetcher-it
          imagePullPolicy: Always
          env:
            - name: S3_DOWNLOAD_BUCKET
              valueFrom:
                configMapKeyRef:
                  name: outputs-infrastructure
                  key: data_pull_s3
            - name: KAFKA_BOOTSTRAP_SERVERS
              valueFrom:
                configMapKeyRef:
                  name: outputs-infrastructure
                  key: msk_bootstrap_brokers
            - name: ZOOKEEPER_ENSEMBLE_HOSTS
              valueFrom:
                configMapKeyRef:
                  name: zookeeper
                  key: connect
            - name: FETCHER_JOB_IMAGE
              valueFrom:
                configMapKeyRef:
                  name: fetcher-dispatcher
                  key: job_image
            - name: FETCHER_JOB_NODE_SELECTOR
              valueFrom:
                configMapKeyRef:
                  name: fetcher-dispatcher
                  key: job_node_selector
            - name: FETCHER_JOB_PULL_POLICY
              valueFrom:
                configMapKeyRef:
                  name: fetcher-dispatcher
                  key: pull_policy
            - name: FETCHER_JOB_MIN_VOLUME_SIZE
              valueFrom:
                configMapKeyRef:
                  name: fetcher-dispatcher
                  key: min_volume_size
            - name: FETCHER_JOB_VOLUME_STORAGE_CLASS
              valueFrom:
                configMapKeyRef:
                  name: fetcher-dispatcher
                  key: storage_class
            - name: CONSUMER_GROUP_ID
              value: fetcher-it
            - name: CONSUMER_TOPIC
              valueFrom:
                configMapKeyRef:
                  name: fetcher-dispatcher
                  key: consumer_topic
            - name: PRODUCER_TOPIC
              valueFrom:
                configMapKeyRef:
                  name: fetcher-dispatcher
                  key: producer_topic
            - name: PYTEST_ARGS
              valueFrom:
                configMapKeyRef:
                  name: pytest
                  key: args
            - name: PYTEST_TIMEOUT
              valueFrom:
                configMapKeyRef:
                  name: pytest
                  key: timeout
            - name: S3_ENDPOINT
              valueFrom:
                configMapKeyRef:
                  name: outputs-infrastructure
                  key: s3_endpoint
      restartPolicy: Never
  backoffLimit: 0
