apiVersion: batch/v1
kind: Job
metadata:
  name: download-helm
  namespace: orchestrator
spec:
  template:
    metadata:
      labels:
        pvc: binaries
    spec:
      restartPolicy: OnFailure
      containers:
      - name: download-helm
        image: alpine/helm:{{.Values.helm.version}}
        command:
        - sh
        args:
        - -c
        - 'mv /usr/bin/helm /binaries'
        volumeMounts:
        - name: binaries
          mountPath: /binaries
      serviceAccountName: downloader
      automountServiceAccountToken: false
      affinity:
        podAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: pvc
                operator: In
                values:
                - binaries
            topologyKey: kubernetes.io/hostname
      volumes:
      - name: binaries
        persistentVolumeClaim:
          claimName: binaries
