apiVersion: batch/v1
kind: Job
metadata:
  name: tez-deploy
spec:
  template:
    spec:
      initContainers:
      - name: wait-for-parent-dir
        image: zookage-util
        args:
        - wait-for-job
        - hdfs-mkdir
      - name: mkdir-tez
        image: zookage-util
        args:
        - hdfs-mkdir
        - /apps/tez
        - tez:tez
        - "755"
        envFrom:
        - configMapRef:
            name: hadoop-env
        env:
        - name: HADOOP_USER_NAME
          value: hdfs
        volumeMounts:
        - name: hadoop-conf
          mountPath: /etc/hadoop/conf
      - name: wait-for-datanode
        image: zookage-util
        args:
        - wait-for-rollout
        - statefulset/hdfs-datanode
      containers:
      - name: upload
        image: zookage-hadoop
        command:
        - $(HADOOP_HOME)/bin/hdfs
        args:
        - dfs
        - -copyFromLocal
        - /opt/tez/share/tez-minimal.tar.gz
        - hdfs:///apps/tez/tez-minimal.tar.gz
        envFrom:
        - configMapRef:
            name: hadoop-env
        env:
        - name: HADOOP_USER_NAME
          value: tez
        volumeMounts:
        - name: hadoop-conf
          mountPath: /etc/hadoop/conf
        - name: package-tez
          mountPath: /opt/tez
      restartPolicy: Never
      volumes:
      - name: hadoop-conf
        configMap:
          name: hadoop-conf
      - name: mnt
        emptyDir: {}
      - name: package-tez
        persistentVolumeClaim:
          claimName: package-tez
