---
apiVersion: batch/v1
kind: Job
metadata:
  generateName: openebs-upgrade-
  namespace: litmus
spec:
  template:
    metadata:
      name: litmus
      labels:
        app: openebs-upgrade
    spec:
      serviceAccountName: litmus
      restartPolicy: Never
      containers:
      - name: ansibletest
        image: openebs/ansible-runner:ci
        imagePullPolicy: IfNotPresent

        env:
          - name: ANSIBLE_STDOUT_CALLBACK
            #value: log_plays, actionable, default
            value: default

            # OpenEBS Version already installed
          - name: FROM_VERSION
            value: ""

            # OpenEBS version to be Upgraded
          - name: TO_VERSION
            value: ""
            
            # Namespace where OpenEBS is deployed
          - name: OPERATOR_NS
            value: ""

            # Image tag for Upgrade Job
          - name: UPGRADE_IMAGE_TAG
            value: ""
 
            # UPGRADE TO CI image tag then the value should be v1.x.x-ci
          - name: UPGRADE_TO_CI
            value: ""

            # set to "true" if you want to upgrade cStor pool and Volumes
          - name: UPGRADE_CSTOR
            value: ""

            # set to "true" if you want to upgrade JIVA volumes        
          - name: UPGRADE_JIVA
            value: ""

            # set to "true" to upgrade OpenEBS control plane
          - name: UPGRADE_CONTROL_PLANE
            value: ""

            # Image tag for NDM to upgrade
          - name: NEW_NDM_TAG
            value: "" 

            # DEPLOY_TYPE is helm or operator
          - name: DEPLOY_TYPE
            value: ""

            # HELM repo to upgrade openebs if the deploy type is helm
            # REPO name for ex: openeb/openebs
          - name: HELM_REPO
            value: ""

            # HELM repo BRANCH to get the upgrade helm chart.
            # BRANCH name be master
          - name: HELM_BRANCH
            value: ""

        command: ["/bin/bash"]
        args: ["-c", "ansible-playbook ./providers/openebs/upgrade/test.yml -i /etc/ansible/hosts -v; exit 0"]
        volumeMounts:
          - name: kubeconfig 
            mountPath: /root/admin.conf
            subPath: admin.conf
          - name: logs
            mountPath: /var/log/ansible 
      volumes: 
        - name: kubeconfig
          configMap: 
            name: kubeconfig 
        - name: logs 
          hostPath:
            path: /mnt/openebs
            type: ""        
