---
apiVersion: batch/v1
kind: Job
metadata:
  generateName: e2e-busybox-deploy-
  namespace: e2e
spec:
  template:
    metadata:
      name: e2e
      labels:
        app: busybox-e2e
    spec:
      serviceAccountName: e2e
      restartPolicy: Never
      containers:
      - name: ansibletest
        image: openebs/ansible-runner:ci
        imagePullPolicy: IfNotPresent
        env:
          - name: ANSIBLE_STDOUT_CALLBACK
            #value: log_plays
            value: default

          - name: PROVIDER_STORAGE_CLASS
            value: openebs-cstor-sparse

            # Application pvc
          - name: APP_PVC
            value: openebs-busybox

            # Application label
            # Use different 'LABEL' for deployment and statefulset application
          - name: APP_LABEL
            value: 'app=busybox-sts'

            # Affinity Label for Application
            # openebs.io/target-affinity if for deployment and statefulset
            # openebs.io/replica-anti-affinity if for statefulset application
            # openebs.io/replica-anti-affinity needs to be added in order to distribute volume replicas.
          - name: AFFINITY_LABEL
            value: openebs.io/target-affinity

            # Application namespace
            # Use different 'namespace' for deployment and statefulset application
          - name: APP_NAMESPACE
            value: app-busybox-ns

            # Use 'deployment'  for Busybox deployment application
            # Use 'statefulset' for Busybox statefulset application
          - name: DEPLOY_TYPE
            value: statefulset
            
            #Persistent Volume storage capacity
          - name: PV_CAPACITY
            value: 5Gi

            #Application replicas for statefulset application
          - name: APP_REPLICA
            value: 'replicas=2'
            
          # Use 'deprovision' for app-clean up
          - name: ACTION
            value: provision

        command: ["/bin/bash"]
        args: ["-c", "ansible-playbook ./apps/busybox/deployers/test.yml -i /etc/ansible/hosts -v; exit 0"]
