Mount PVC in cronjob and statefulset

3.9k views Asked by At

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?

1

There are 1 answers

3
switchboard.op On BEST ANSWER

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.