1

I have two services that I would like to access a PersistentVolumeClaim.

One is a StatefulSet that is reading from the volume (and serving content to end users), the other is a Kubernetes CronJob that periodically updates the contents of the data in obtained by a PVC.

Right now I'm running into the issue that my PVC is backed by a PV (not NFS, Ceph, or the like) and one service grabs the volume making the other not start.

How can I make it so both of these services have access to the volume?

And is there a way to add a CronJob to my StatefulSet the same way I add more containers?

Darrien
  • 71
  • 2
  • 12

1 Answers1

3

Have you checked the accessModes of your pv and pvc?

If you want more than one pod to be able to mount the volume you'll need to use ReadOnlyMany or ReadWriteMany

Persistent Volume Docs

As for your second question, no, there's no way to "add a CronJob to [a] StatefulSet". They are separate and distinct API objects.

switchboard.op
  • 1,878
  • 7
  • 26
  • Thanks friend! In that case I just need to make it so my CronJob runs on the same pod as my StatefulSet, right? – Darrien Nov 07 '18 at 15:20
  • 1
    Update - I ended up just hacking it and removing my CronJob. Then adding it as a container in my StatefulSet so it will now run as an interval. My PV only has accessModes ReadWriteOnce. Yay beta features. Thanks for the help friend :) – Darrien Nov 08 '18 at 02:05
  • 1
    According to the docs that you pasted, access modes are about nodes, not pods. You can mount a pvc on multiple pods on the same node, even if set to ReadWriteOnce. – geedoubleya Jun 09 '22 at 09:35