apiVersion: batch/v1
kind: Job
metadata:
  name: download-kubectl
  namespace: orchestrator
spec:
  template:
    metadata:
      labels:
        pvc: binaries
    spec:
      restartPolicy: OnFailure
      containers:
      - name: download-kubectl
        image: fedora:32
        command:
        - bash
        args:
        - -c
        - 'curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl && chmod +x ./kubectl && mv ./kubectl /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
