apiVersion: batch/v1
kind: Job
metadata:
  name: theodolite
spec:
  template:
    spec:
      securityContext:
        runAsUser: 0 # Set the permissions for write access to the volumes.
      containers:
        - name: lag-analysis
          image: ghcr.io/cau-se/theodolite-slo-checker-lag-trend:latest
          ports:
          - containerPort: 80
            name: analysis
        - name: theodolite
          image: ghcr.io/cau-se/theodolite:latest
          imagePullPolicy: Always
          env:
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            # - name: MODE
            #   value: yaml-executor # Default is `yaml-executor`
            - name: THEODOLITE_EXECUTION
              value: "/deployments/execution/execution.yaml" # The name of this file must correspond to the filename of the execution, from which the config map is created.
            - name: THEODOLITE_BENCHMARK
              value: "/deployments/benchmark/benchmark.yaml" # The name of this file must correspond to the filename of the benchmark, from which the config map is created.
            - name: THEODOLITE_APP_RESOURCES
              value: "/deployments/benchmark-resources"
            - name: RESULTS_FOLDER # Folder for saving results
              value: /deployments/results # Default is the pwd (/deployments)
            # - name: CREATE_RESULTS_FOLDER # Specify whether the specified result folder should be created if it does not exist.
            #   value: "false" # Default is false.
          volumeMounts:
            - mountPath: "/deployments/results" # the mounted path must corresponds to the value of `RESULT_FOLDER`.
              name: theodolite-pv-storage
            - mountPath: "/deployments/benchmark-resources" # must correspond to the value of `THEODOLITE_APP_RESOURCES`.
              name: benchmark-resources
            - mountPath: "/deployments/benchmark"  # must correspond to the value of `THEODOLITE_BENCHMARK`.
              name: benchmark
            - mountPath: "/deployments/execution" # must correspond to the value of `THEODOLITE_EXECUTION`.
              name: execution
      restartPolicy: Never
      # Uncomment if RBAC is enabled and configured
      serviceAccountName: theodolite
      # Multiple volumes are needed to provide the corresponding files.
      # The names must correspond to the created configmaps and the volumeMounts.
      volumes:
        - name: theodolite-pv-storage
          persistentVolumeClaim:
            claimName: theodolite-pv-claim
        - name: benchmark-resources
          configMap:
            name: benchmark-resources-configmap
        - name: benchmark
          configMap:
            name: benchmark-configmap
        - name: execution
          configMap:
            name: execution-configmap
  backoffLimit: 4