---
apiVersion: batch/v1
kind: Job
metadata:
  generateName: litmus-cstor-memcheck-
  namespace: litmus
spec:
  template:
    metadata:
      labels:
        name: litmus
        app: memcheck-cstor-test
    spec:
      serviceAccountName: litmus
      restartPolicy: Never
      containers:
      - name: ansibletest
        image: openebs/ansible-runner:ci
        imagePullPolicy: Always
        env: 
          - name: ANSIBLE_STDOUT_CALLBACK
            value: default
 
          - name: APP_LABEL
            value: 'name=prometheus'

          - name: APP_PVC
            value: 'prometheus-claim'

          - name: APP_NAMESPACE
            value: app-prometheus

          - name: TARGET_NAMESPACE
            value: openebs

        command: ["/bin/bash"]
        args: ["-c", "ansible-playbook ./prometheus/functional/memcheck/test.yml -i /etc/ansible/hosts -v; exit 0"]
        volumeMounts:
          - name: logs
            mountPath: /var/log/ansible
        tty: true
      - name: logger
        image: openebs/logger
        env:
          - name: MY_POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: MY_POD_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
          # spec.volumes is not supported via downward API
          - name: MY_POD_HOSTPATH
            value: /mnt/memcheck
        command: ["/bin/bash"]
        args: ["-c", "./logger.sh -d ansibletest -r maya,openebs,pvc,prometheus; exit 0"]
        volumeMounts:
          - name: kubeconfig
            mountPath: /root/admin.conf
            subPath: admin.conf
          - name: logs
            mountPath: /mnt
        tty: true
      volumes:
        - name: kubeconfig
          configMap:
            name: kubeconfig
        - name: logs
          hostPath:
            path: /mnt/memcheck
            type: ""
