<p>I have created 3 CronJobs in Kubernetes. The format is exactly the same for every one of them except the names. These are the following specs:</p>
<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: test-job-1 # for others it's test-job-2 and test-job-3
  namespace: cron-test
spec:
  schedule: &quot;* * * * *&quot;
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
          - name: test-job-1 # for others it's test-job-2 and test-job-3
            image: busybox
            imagePullPolicy: IfNotPresent
            command:
            - &quot;/bin/sh&quot;
            - &quot;-c&quot;
            args:
            - cd database-backup &amp;&amp; touch $(date +%Y-%m-%d:%H:%M).test-job-1 &amp;&amp; ls -la # for others the filename includes test-job-2 and test-job-3 respectively
            volumeMounts:
            - mountPath: &quot;/database-backup&quot;
              name: test-job-1-pv # for others it's test-job-2-pv and test-job-3-pv
          volumes:
          - name: test-job-1-pv # for others it's test-job-2-pv and test-job-3-pv
            persistentVolumeClaim:
              claimName: test-job-1-pvc # for others it's test-job-2-pvc and test-job-3-pvc
</code></pre>
<p>And also the following Persistent Volume Claims and Persistent Volume:</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: test-job-1-pvc # for others it's test-job-2-pvc or test-job-3-pvc
  namespace: cron-test
spec:
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Delete
  resources:
    requests:
      storage: 1Gi
  volumeName: test-job-1-pv # depending on the name it's test-job-2-pv or test-job-3-pv
  storageClassName: manual
  volumeMode: Filesystem
</code></pre>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: test-job-1-pv # for others it's test-job-2-pv and test-job-3-pv
  namespace: cron-test
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: &quot;/database-backup&quot;
</code></pre>
<p>So all in all there are 3 CronJobs, 3 PersistentVolumes and 3 PersistentVolumeClaims. I can see that the PersistentVolumeClaims and PersistentVolumes are bound correctly to each other. So <code>test-job-1-pvc</code> &lt;--&gt; <code>test-job-1-pv</code>, <code>test-job-2-pvc</code> &lt;--&gt; <code>test-job-2-pv</code> and so on. Also the pods associated with each PVC are are the corresponding pods created by each CronJob. For example <code>test-job-1-1609066800-95d4m</code> &lt;--&gt; <code>test-job-1-pvc</code> and so on. After letting the cron jobs run for a bit I create another pod with the following specs to inspect <code>test-job-1-pvc</code>:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: data-access
  namespace: cron-test
spec:
  containers:
    - name: data-access
      image: busybox
      command: [&quot;sleep&quot;, &quot;infinity&quot;]
      volumeMounts:
        - name: data-access-volume
          mountPath: /database-backup
  volumes:
    - name: data-access-volume
      persistentVolumeClaim:
        claimName: test-job-1-pvc
</code></pre>
<p>Just a simple pod that keeps running all the time. When I get inside that pod with <code>exec</code> and see inside the <code>/database-backup</code> directory I see all the files created from all the pods created by the 3 CronJobs.</p>
<p><strong>What I exepected to see?</strong></p>
<p>I expected to see only the files created by <code>test-job-1</code>.</p>
<p>Is this something expected to happen? And if so how can you separate the PersistentVolumes to avoid something like this?</p>

David Prifti
<p>I suspect this is caused by the PersistentVolume definition: if you really only changed the name, all volumes are mapped to the same folder on the host.</p>
<pre><code> hostPath:
    path: &quot;/database-backup&quot;
</code></pre>
<p>Try giving each volume a unique folder, e.g.</p>
<pre><code> hostPath:
    path: &quot;/database-backup/volume1&quot;
</code></pre>
