apiVersion: batch/v1
kind: Job
metadata:
  name: "{{.Name}}-transcode"
  namespace: handbrk8s
spec:
  backoffLimit: 20
  template:
    metadata:
      name: "{{.Name}}-transcode"
      labels:
        job-type: transcode
        video: "{{.Name}}"
    spec:
      initContainers:
      - name: prep
        image: alpine:3.5
        command: ["sh"]
        args:
        - "-xc"
        - "mkdir -p '{{.OutputDir}}'"
        volumeMounts:
        - mountPath: /ponyshare
          name: ponyshare
      containers:
      - name: handbrake
        image: carolynvs/handbrakecli:1.2.0
        resources:
          requests:
            cpu: "3"
        args:
        - "--preset-import-file"
        - "/config/ghb/presets.json"
        - "-i"
        - "{{.InputPath}}"
        - "-o"
        - "{{.OutputPath}}"
        - "--preset"
        - "{{.Preset}}"
        volumeMounts:
        - mountPath: /ponyshare
          name: ponyshare
        - name: handbrakecli-config
          mountPath: /config/ghb
      restartPolicy: Never
      volumes:
      - name: ponyshare
        persistentVolumeClaim:
          claimName: ponyshare
      - name: handbrakecli-config
        configMap:
          name: handbrakecli
