<p>Is there a way to run a scheduled job that would pull some files regurarly on a mounted shared volume?</p>
<p>I have tried cronjob but apparently it doesn't supposed external filesystems</p>
<p>thanks in advance.</p>

zozo6015
<p>CronJobs should be able to mount PVC just as any other resource which spawn Pods, you can just add a <code>volumeMounts</code> section under the <code>container</code> template, and then a <code>volume</code> section under <code>template</code>.</p>
<p>Something like the following:</p>
<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: example-name
spec:
  schedule: '0 * * * *'
  jobTemplate:
    spec:
      completions: 1
      template:
        spec:
          containers:
          - name: example-container-name
            image: your-docker-repo/your-docker-image:the-tag
            volumeMounts:
            - name: data
              mountPath: /internal/path/to/mount/pvc
          volumes:
          - name: data
            persistentVolumeClaim:
              claimName: example-claim
</code></pre>
<p>This should mount <code>example-claim</code> PVC to the CronJob's Pod when the Pod is spawned.</p>
<p>Basically there are two sections.. under each container volumeMounts list the volumes mounted by the container, at which path and a few more configuration. All the volumeMounts entries should be defined once in the volumes section which associate names (that act as keys for the spec) and claims or empty-dir.</p>
<p>As for creating the PVC, let me link you the documentation (<a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/storage/persistent-volumes/</a>)</p>
<p>What you want to do basically is to create a Persistent Volume which points to your mounted shared volume (what is it, a nfs storage? The declaration changes slightly, depending on what exactly you want to mount) and then a Claim (PVC) in the same namespace of the CronJob which will bound to the PV.</p>
<p>If you are unsure about the correct indentation of the various objects or where to put things, check the practical API Reference Docs (<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#cronjob-v1beta1-batch" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#cronjob-v1beta1-batch</a>)</p>
