---
apiVersion: batch/v1
kind: Job
metadata:
  generateName: pod-delete-

  # Executed on application's namespace in case of automated runs 
  # Provide appropriate namespace if executed manually 
  # namespace: litmus
spec:
  template:
    metadata:
      labels:
        experiment: pod-delete
    spec:
      # Placeholder that is updated by the executor for automated runs
      # Provide appropriate SA (with desired permissions) if executed manually
      serviceAccountName: CHAOS_SERVICE_ACCOUNT

      restartPolicy: Never
      containers:
      - name: ansibletest
        image: openebs/ansible-runner:ci
        imagePullPolicy: Always
        env:
          - name: ANSIBLE_STDOUT_CALLBACK
            value: actionable

          - name: APP_NAMESPACE
            value: default 

          - name: APP_LABEL
            value: 'app=nginx'

          - name: APP_KIND
            value: deployment

          - name: TOTAL_CHAOS_DURATION
            value: "15"

          - name: CHAOS_INTERVAL
            value: "5"

          - name: FORCE
            value: "true"

          - name: CHAOSENGINE
            value: "engine-nginx"

          - name: CHAOSKUBE_SVC_ACC
            valueFrom:
              fieldRef:
                fieldPath: spec.serviceAccountName

        command: ["/bin/bash"]
        args: ["-c", "ansible-playbook ./experiments/chaos/kubernetes/pod_delete/test.yml -i /etc/ansible/hosts; exit 0"]

