 #
 # Copyright © 2018 IBM Corporation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
 #
 #    http://www.apache.org/licenses/LICENSE-2.0
 #
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #

apiVersion: batch/v1
kind: Job
metadata:
  name: hello
  namespace: default
  labels:
    name: hello
    job: hello
spec:
  completions: 2
  parallelism: 2
  template:
    metadata:
      name: hello
      labels:
        name: hello
        job: hello
    spec:
      hostNetwork: true
      containers:
        - name: hello
          imagePullPolicy: Always
          image: kube-mpi:centos
          volumeMounts:
            - mountPath: /root/.ssh
              name: sshkey
            - mountPath: /run
              name: sockets
            - mountPath: /etc/libibverbs.d
              name: verbs
            - mountPath: /sys/class/infiniband_verbs/
              name: ibdevices
          env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: PYTHONUNBUFFERED
              value: '1'
            - name: PYTHONOPTIMIZE
              value: '1'
            - name: POD_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          command: ["/usr/local/bin/bootstrap.py"]
          args:
          - --network=10.1.0.0/16
          - --job_name=hello
          - --cmd=/hello
          ports:
          - containerPort: 22
            hostPort: 22
      restartPolicy: Never
      volumes:
      - name: sshkey
        hostPath:
          path: /root/.ssh
      - name: sockets
        hostPath:
          path: /run
      - name: verbs
        hostPath:
          path: /etc/libibverbs.d
      - name: ibdevices
        hostPath:
          path: /sys/class/infiniband_verbs/
