apiVersion: batch/v1
kind: Job
metadata:
  name: benchmark-job-id
  labels:
    app: benchmark-ai
    action-id: ACTION_ID
    client-id: CLIENT_ID
    created-by: executor
    custom_label: my-value
    other_label: other-value
    parent-action-id: parentactionid
spec:
  template:
    metadata:
      labels:
        app: benchmark-ai
        action-id: ACTION_ID
        client-id: CLIENT_ID
        created-by: executor
        custom_label: my-value
        other_label: other-value
        parent-action-id: parentactionid
      annotations:
        iam.amazonaws.com/role: benchmark-host
    spec:
      serviceAccountName: benchmark
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - benchmark-ai
            topologyKey: kubernetes.io/hostname
      initContainers: []
      containers:
      - name: benchmark
        image: edisongustavo/bai-benchmarks-hello-world:latest
        resources:
          limits:
            nvidia.com/gpu: 0
        command:
        - python3
        - hello-world.py
        securityContext:
          privileged: false
        env:
        - name: BENCHMARK_AI
          value: fifo
        - name: BENCHMARK_AI_FIFO_FILEPATH
          value: /tmp/benchmark-ai/fifo
        - name: BENCHMARK_AI_FIFO_MAX_WAIT_TIME
          value: '60'
        - name: FIST_VAL
          value: VAR
        - name: SECOND_VAL
          value: VAR
        - name: FOO
          value: bar
        volumeMounts:
        - mountPath: /tmp/benchmark-ai
          name: benchmark-ai
        - name: dshm
          mountPath: /dev/shm
      - name: metrics-pusher
        image: benchmarkai/metrics-pusher:ffed580
        env:
        - name: BENCHMARK_AI_FIFO_FILEPATH
          value: /tmp/benchmark-ai/fifo
        - name: BACKEND
          value: kafka
        - name: BACKEND_ARG_ACTION_ID
          value: ACTION_ID
        - name: BACKEND_ARG_CLIENT_ID
          value: CLIENT_ID
        - name: BACKEND_ARG_BOOTSTRAP_SERVERS
          valueFrom:
            configMapKeyRef:
              name: outputs-infrastructure
              key: msk_bootstrap_brokers
        - name: BACKEND_ARG_KEY
          value: CLIENT_ID
        - name: BACKEND_ARG_TOPIC
          value: BAI_METRICS
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: CUSTOM_LABEL_CUSTOM_LABEL
          value: my-value
        - name: CUSTOM_LABEL_OTHER_LABEL
          value: other-value
        - name: CUSTOM_LABEL_PARENT-ACTION-ID
          value: parentactionid
        volumeMounts:
        - mountPath: /tmp/benchmark-ai
          name: benchmark-ai
      - name: metrics-extractor
        image: benchmarkai/metrics-extractor:b0b9185
        env:
        - name: ANUBIS_POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: ANUBIS_POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: ANUBIS_METRICS
          value: '[{"name": "accuracy", "units": "%", "pattern": "YWNjdXJhY3k9KFstK10/XGQqXC5cZCt8XGQrKQ=="},
            {"name": "throughput", "units": "images/sec", "pattern": "dGhyb3VnaHB1dD0oWy0rXT9cZCpcLlxkK3xcZCsp"}]'
        - name: BENCHMARK_AI
          value: fifo
        - name: BENCHMARK_AI_FIFO_FILEPATH
          value: /tmp/benchmark-ai/fifo
        volumeMounts:
        - mountPath: /tmp/benchmark-ai
          name: benchmark-ai
      nodeSelector:
        beta.kubernetes.io/instance-type: t2.small
        node.type: bai-worker
        failure-domain.beta.kubernetes.io/zone: us-east-1a
      restartPolicy: OnFailure
      volumes:
      - name: benchmark-ai
        emptyDir: {}
      - name: dshm
        emptyDir:
          medium: Memory
  backoffLimit: 4
