Search code examples
kuberneteskubeflowkubeflow-katib

How to mount PVC to a (katib) Job specification?


I'd like to mount a PVC to a (katib) Job specification but can't find anything in the documentation nor any example?

I'm pretty sure that this should be possible as a Job is orchestrating pods and pods can do so. Or am I missing something?

Please find below the respective (katib) job specification

apiVersion: batch/v1
kind: Job
spec:
  template:
    spec:
      containers:
      - env:
        - name: training-container
          image: docker.io/romeokienzler/claimed-train-mobilenet_v2:0.3
          command:
            - "ipython"
            - "/train-mobilenet_v2.ipynb"
            - "optimizer=${trialParameters.optimizer}"
      restartPolicy: Never

Solution

  • You can add the volume and volume mount to your Katib job template so that all the HPO jobs on Katib can share the same volumes. e.g.

    apiVersion: batch/v1
    kind: Job
    spec:
      template:
        spec:
          containers:
            - name: training-container
              image: docker.io/romeokienzler/claimed-train-mobilenet_v2:0.4
              command:
                - "ipython"
                - "/train-mobilenet_v2.ipynb"
                - "optimizer=${trialParameters.optimizer}"
              volumeMounts:
                - mountPath: /data/
                  name: data-volume
          restartPolicy: Never
          volumes:
              - name: data-volume
                persistentVolumeClaim:
                  claimName: data-pvc
    

    Also make sure your pvc is read write many so the pod on different nodes can mount on the same volume at the same time.