#!/bin/bash

# Copyright 2020 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License 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: kperf-job-${EXPERIMENT_ID}-${SETUP_ID}-${WORKLOAD_ID}
spec:
  template:
    spec:
      containers:
      - name: kperf-eventing-driver-job
        image: ${IMAGE_NAME}
        imagePullPolicy: Always
        command: ["/kperf"]
        args: [ "eventing", "driver" ]
        env:
        - name: TARGET_URL
          value: "${TARGET_URL}"
        - name: KAFKA_BOOTSTRAP_SERVERS
          value: "${KAFKA_BOOTSTRAP_SERVERS}"
        - name: KAFKA_TOPIC
          value: "${KAFKA_TOPIC}"
        - name: KAFKA_GROUP
          value: "${KAFKA_GROUP}"
        - name: KAFKA_NET_TLS_ENABLE
          value: "${KAFKA_NET_TLS_ENABLE}"
        - name: KAFKA_NET_SASL_ENABLE
          value: "${KAFKA_NET_SASL_ENABLE}"
        - name: KAFKA_NET_SASL_USER
          value: "${KAFKA_NET_SASL_USER}"
        - name: KAFKA_NET_SASL_PASSWORD
          value: "${KAFKA_NET_SASL_PASSWORD}"
        - name: EXPERIMENT_ID
          value: "$EXPERIMENT_ID"
        - name: SETUP_ID
          value: "$SETUP_ID"
        - name: WORKLOAD_ID
          value: "$WORKLOAD_ID"
        - name: START
          value: "$START"
        - name: DURATION
          value: "$DURATION"
        - name: TEST_DURATION
          value: "$TEST_DURATION"
        - name: CONCURRENT
          value: "$CONCURRENT"
        resources:
          requests:
            cpu: "1"
            memory: "2G"
          limits:
            cpu: "1"
            memory: "8G"
      restartPolicy: Never
  backoffLimit: 4
