# This version of the script has been updated to use unique names
# See https://github.com/kubeflow/testing/issues/444
# Its also using an init container to check out the code.
apiVersion: batch/v1
kind: Job
metadata:
  generateName: deploy-master-
  namespace: kubeflow-test-infra
  labels:
    job: deploy-master-oneoff
    version: master
spec:
  backoffLimit: 1
  template:
    metadata:
      labels:
        job: deploy-master-oneoff
        version: master
    spec:
      initContainers:
      - command:        
        - /usr/local/bin/checkout_repos.sh         
        - --repos=kubeflow/kfctl@HEAD:,kubeflow/testing@HEAD
        - --src_dir=/src
        env:
        - name: PYTHONPATH
          value: /src/kubeflow/testing/py
        - name: GOOGLE_APPLICATION_CREDENTIALS
          value: /secret/gcp-credentials/key.json
        image: gcr.io/kubeflow-ci/test-worker@sha256:dd559f89b3cbd926ec563559995f25025eecc6290b3146f17f82d2f084d07ee2
        imagePullPolicy: IfNotPresent
        name: checkout
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /secret/gcp-credentials
          name: gcp-credentials
          readOnly: true
        - mountPath: /src
          name: src
      containers:
      - name: deploy
        image: gcr.io/kubeflow-ci/test-worker@sha256:dd559f89b3cbd926ec563559995f25025eecc6290b3146f17f82d2f084d07ee2
        env:
        - name: GOOGLE_APPLICATION_CREDENTIALS
          value: /secret/gcp-credentials/key.json
        - name: PYTHONPATH
          value: /src/kubeflow/testing/py
        command:
        - python
        - -m
        - kubeflow.testing.create_unique_kf_instance
        - --apps_dir=/src/apps
        - --kubeflow_repo=/src/kubeflow/kfctl
        - --name=kf-vmaster-{uid}
        - --project=kubeflow-ci-deployment
        - --zone=us-central1-a
        - --kfctl_config=https://raw.githubusercontent.com/kubeflow/manifests/master/kfdef/kfctl_gcp_iap.yaml
        volumeMounts:
        - name: gcp-credentials
          mountPath: /secret/gcp-credentials
          readOnly: true
        - mountPath: /src
          name: src
      restartPolicy: Never
      volumes:
      - name: gcp-credentials
        secret:
          secretName: gcp-credentials
      - name: src
        emptyDir: {}
