apiVersion: batch/v1
kind: Job
metadata:
  name: worker
  labels:
    name: tensorflow-worker
spec:
  completions: 3
  parallelism: 3
  template:
    metadata:
      name: tensorflow-worker
      labels:
        name: tensorflow-worker
        role: worker
        job: mnist
    spec:
      nodeName: minion1
      restartPolicy: Never
      containers:
        - name: worker
          image: IMAGE
          command: ["bootstrap"]
          args:
          - --ps_num=1
          - --worker_num=2
          - --job_name=mnist
          - --role=worker
          - --cmd=python /code/mnist.py --data_dir=/input --model_dir=/output/trained_model --log_dir=/output/training_log
          env:
            - name: POD_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          ports:
          - containerPort: 2222
          volumeMounts:
          - name: code
            mountPath: /code
          - name: input
            mountPath: /input/
          - name: output
            mountPath: /output/
      volumes:
      - hostPath:
          path: /code/distributeTensorflowExample/
        name: code
      - hostPath:
          path: /input/MNIST_data/
        name: input
      - hostPath:
          path: /tmp/
        name: output
