---
apiVersion: batch/v1
kind: Job
metadata:
  generateName: pod-delete-
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%
      serviceAccountName: nginx
      restartPolicy: Never
      containers:
      - name: ansibletest
        image: ansible-runner:v3
        imagePullPolicy: Never
        env:
          - name: ANSIBLE_STDOUT_CALLBACK
            value: 'default'

          # provide application namespace
          - name: APP_NAMESPACE
            value: 'default'

          # provide application labels
          - name: APP_LABEL
            value: 'run=myserver'

          - name: TOTAL_CHAOS_DURATION
            value: '20'

          - name: CHAOS_INTERVAL
            value: '5'

          - name: FORCE
            value: 'true'

          ## env var that describes the library used to execute the chaos
          ## default: litmus. Supported values: litmus, powerfulseal
          - name: LIB
            value: ''

          - name: CHAOSENGINE
            value: ''

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

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

