# Mounting persistent volumes of a statefulset from a job

**URL:** <https://discuss.kubernetes.io/t/mounting-persistent-volumes-of-a-statefulset-from-a-job/15216>\
**Category:** General Discussions\
**Created:** [March 18, 2021, 4:29pm UTC](https://discuss.kubernetes.io/t/mounting-persistent-volumes-of-a-statefulset-from-a-job/15216 "2021-03-18T16:29:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikkko](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/nikkko/32/7209_2.png) [@nikkko](https://discuss.kubernetes.io/u/nikkko)\
**Post date:** [March 18, 2021, 4:29pm UTC](https://discuss.kubernetes.io/t/mounting-persistent-volumes-of-a-statefulset-from-a-job/15216/1 "2021-03-18T16:29:21Z")

</div>

Asking for help? Comment out what you need so we can get more information to help you!

### Cluster information:

Kubernetes version: 1.19.3 (k3s)  
Cloud being used: bare-metal  
Installation method: na  
Host OS: Unbuntu  
CNI and version: na  
CRI and version: na

Hello

I would like to execute a Cronjob which mounts volumes from pods of a statefulset.  
To do this, i wrote this in the yaml :

- name: …  
displayName: …

The pb is that the “claimName” is a “fixed” string.  
Here “datadir-db-0” is the claim for the first pod of the statefulset (which has the label app=db)  
On the second pod of the statefulset, the second pod executed by the job will fail because “datadir-db-0” claim name does not exist.“datadir-db-1” claimname should be used instead.

How to mount the right persistent volume of the statfulset from each pods executed by the job ?

Regards.

nikkko
