apiVersion: batch/v1
kind: Job
metadata:
  name: "{{.Name}}-upload"
  namespace: handbrk8s
spec:
  backoffLimit: 100
  template:
    metadata:
      name: "{{.Name}}-upload"
      labels:
        job-type: upload
        video: "{{.Name}}"
    spec:
      initContainers:
      - name: jobchain
        image: carolynvs/jobchain:latest
        imagePullPolicy: Always
        args:
        - "--namespace"
        - "handbrk8s"
        - "--name"
        - "{{.WaitForJob}}"
      containers:
      - name: uploader
        image: carolynvs/handbrk8s-uploader:latest
        imagePullPolicy: Always
        args:
        - "-f"
        - "{{.TranscodedFile}}"
        - "--suffix"
        - "{{.DestinationSuffix}}"
        - "--plex-server"
        - "{{.PlexServer}}"
        - "--plex-library"
        - "{{.PlexLibrary}}"
        - "--plex-share"
        - "{{.PlexShare}}"
        - "--raw"
        - "{{.RawFile}}"
        envFrom:
        - secretRef:
            name: plex-secret
        volumeMounts:
        - mountPath: /ponyshare
          name: ponyshare
        - mountPath: /plex
          name: plex
      restartPolicy: Never
      volumes:
      - name: ponyshare
        persistentVolumeClaim:
          claimName: ponyshare
      - name: plex
        persistentVolumeClaim:
          claimName: plex
