# Mount Jupyterhub Singleuser PV to extra Container

**URL:** <https://discourse.jupyter.org/t/mount-jupyterhub-singleuser-pv-to-extra-container/11771>\
**Category:** Zero to JupyterHub on Kubernetes\
**Tags:** how-to, help-wanted\
**Created:** [November 20, 2021, 7:14am UTC](https://discourse.jupyter.org/t/mount-jupyterhub-singleuser-pv-to-extra-container/11771 "2021-11-20T07:14:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prashant\_Raghav](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/prashant_raghav/32/3518_2.png) [@Prashant\_Raghav](https://discourse.jupyter.org/u/Prashant_Raghav)\
**Post date:** [November 20, 2021, 7:14am UTC](https://discourse.jupyter.org/t/mount-jupyterhub-singleuser-pv-to-extra-container/11771/1 "2021-11-20T07:14:45Z")

</div>

Hi ,  
Currently I am working on a usecase , where I need to introduce a side-car container inside Jupyterhub pod , which monitors /home/[username] directory of the Notebook container , for this use case I have added new container in extraContainer section of values.yaml , exactly on this line [zero-to-jupyterhub-k8s/values.yaml at da8b979b982e0951bbbdc33f564ff1e33fa768b9 · jupyterhub/zero-to-jupyterhub-k8s · GitHub](https://github.com/jupyterhub/zero-to-jupyterhub-k8s/blob/da8b979b982e0951bbbdc33f564ff1e33fa768b9/jupyterhub/values.yaml#L356)

But my use-case needs the new side container to mount the dynamic PV created by notebook container , I am talking about PV section here

> <https://github.com/jupyterhub/zero-to-jupyterhub-k8s/blob/da8b979b982e0951bbbdc33f564ff1e33fa768b9/jupyterhub/values.yaml#L365>

How can this be achieved , Technically PV’s can be mounted to multiple containers , but this being a dynamic provisioned PV is creating a confusion?

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [November 22, 2021, 11:35pm UTC](https://discourse.jupyter.org/t/mount-jupyterhub-singleuser-pv-to-extra-container/11771/2 "2021-11-22T23:35:52Z")

</div>

Hi! It’s not clear what you’re trying to achieve.

Could you show us your full configuration file with secrets redacted, this might help clarify things.

---

<div class="post-metadata">

**Author:** ![Prashant\_Raghav](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/prashant_raghav/32/3518_2.png) [@Prashant\_Raghav](https://discourse.jupyter.org/u/Prashant_Raghav)\
**Post date:** [November 23, 2021, 2:05pm UTC](https://discourse.jupyter.org/t/mount-jupyterhub-singleuser-pv-to-extra-container/11771/3 "2021-11-23T14:05:31Z")

</div>

Hi @manics , thanks for the reply , I will share snipets from my values.yaml file (single user section) and try to describe my use case here

```auto
singleuser:
  extraContainers:
    - name: dind
      image: docker:19.03-rc-dind
      lifecycle:
        postStart:
          exec:
            command:
              - "sh"
              - "-c"
              - "update-ca-certificates; echo Certificates Updated"
      securityContext:
        privileged: true
      volumeMounts:
        - name: dind-storage
          mountPath: /var/lib/docker
        - name: docker-cert
          mountPath: /usr/local/share/ca-certificates/
    - name: sync-service
      image: private-repo/sync-service
   
<other section omitted from here>
    static:
      pvcName:
      subPath: '{username}'
    capacity: 10Gi
    homeMountPath: '/home/{username}'
    dynamic:
      storageClass: nfs-client
      pvcNameTemplate: claim-{username}{servername}
      volumeNameTemplate: volume-{username}{servername}
      storageAccessModes: [ReadWriteOnce]

```

Basically I want to mount /home/{username} this path in sync-service container as well.

As you can see the new PV and PVC is created exclusively for Notebook container and are never mounted on extra containers added in extraContainer section , My question is can this dynamic PV be some-how mounted on sync-service container?

I apologise , If I am unable to make my use case clear , please let me know if something is not understood or missing?  
Thanks in advance…

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [November 25, 2021, 6:58pm UTC](https://discourse.jupyter.org/t/mount-jupyterhub-singleuser-pv-to-extra-container/11771/4 "2021-11-25T18:58:51Z")

</div>

It might be enough to add a volumeMounts and volume section that references the PersistentVolumeClaim name of dynamically created PVC. The name `claim-{username}{servername}` should be expanded in `extraContainers`:

> <https://github.com/jupyterhub/kubespawner/blob/be151a4a8fae811e136e987f4ebbb4f03482d57a/kubespawner/spawner.py#L1270-L1294>

See for example [kubernetes - How can I mount the same persistent volume on multiple pods? - Stack Overflow](https://stackoverflow.com/questions/62309755/how-can-i-mount-the-same-persistent-volume-on-multiple-pods)
