apiVersion: batch/v1
kind: Job
metadata:
  name: prepare-cod
  namespace: medtune
spec:
  template:
    spec:
      containers:
      - name: prepare-cod-data
        image: google/cloud-sdk:latest
        args: [ 
          "gsutil",
          "cp",
          "-r",
          "gs://medtune/datasets/catvsdog/*",  
          "/nfs/data/cod" ]
          
        volumeMounts:
          - mountPath: /nfs
            name: nfs-volume

          - mountPath: /home/creds.json
            name: gcs
            readOnly: true

        env:
        - name: GOOGLE_APPLICATION_CREDENTIALS
          value: "/home/creds.json"

      - name: prepare-mobilenet-weights
        image: google/cloud-sdk:latest
        args: [ 
          "gsutil",
          "cp",
          "-r",
          "gs://medtune/ptmodels/ckpt_mobilenet/*",  
          "/nfs/weights/mobilenet",
        ]  
        volumeMounts:
          - mountPath: /nfs
            name: nfs-volume

        env:
        - name: GOOGLE_APPLICATION_CREDENTIALS
          value: "/home/creds.json"

      restartPolicy: Never
      volumes:
        - name: nfs-volume
          persistentVolumeClaim:
            claimName: train-pvc
            
        - name: gcs
          secret:
            secretName: gcs-creds

  backoffLimit: 1 # Number of retries