# Mount local directory to jupyterhub pods

**URL:** <https://discourse.jupyter.org/t/mount-local-directory-to-jupyterhub-pods/15890>\
**Category:** Zero to JupyterHub on Kubernetes\
**Tags:** jupyterhub, help-wanted\
**Created:** [September 21, 2022, 9:21pm UTC](https://discourse.jupyter.org/t/mount-local-directory-to-jupyterhub-pods/15890 "2022-09-21T21:21:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![relyativist](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/relyativist/32/7989_2.png) [@relyativist](https://discourse.jupyter.org/u/relyativist)\
**Post date:** [September 21, 2022, 9:21pm UTC](https://discourse.jupyter.org/t/mount-local-directory-to-jupyterhub-pods/15890/1 "2022-09-21T21:21:09Z")

</div>

I am trying to mount local directory to spawned jupyterlab with kubernetes, but spawner freezes on last

1. I created cluster with with kind:

```auto
kind create cluster --config ./multinode-conf.yaml --name jupyter

```

1. I have default storageclass output:

```auto
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
standard (default) rancher.io/local-path Delete WaitForFirstConsumer false 87s

```

1. created namespace:

```auto
kubectl create namespace jupyter

```

1. installed helm:

```auto
helm install jhub-datascience jupyterhub/jupyterhub -f scipy-jhub-values-kind.yaml -n jupyter --timeout 180s

```

1. output of kubectl get pods

```auto
NAME READY STATUS RESTARTS AGE
continuous-image-puller-mflnt 1/1 Running 0 11s
continuous-image-puller-pzm56 1/1 Running 0 11s
hub-54cc8f7c5c-v4xch 0/1 ContainerCreating 0 11s
proxy-7699bccdcb-t6wfc 1/1 Running 0 11s
user-scheduler-5498fc849d-ggv8h 0/1 ContainerCreating 0 11s
user-scheduler-5498fc849d-ql9bm 1/1 Running 0 11s
user-scheduler-5498fc849d-ggv8h 0/1 Running 0 12s
user-scheduler-5498fc849d-ggv8h 1/1 Running 0 14s
hub-54cc8f7c5c-v4xch 0/1 Running 0 21s

```

1. Event log freezed on

```auto
Event log
Server requested
2022-09-21T21:16:00.492361Z [Normal] Successfully assigned jupyter/jupyter-myname to jupyter-worker
2022-09-21T21:16:01Z [Normal] Container image "jupyterhub/k8s-network-tools:2.0.0" already present on machine
2022-09-21T21:16:01Z [Normal] Created container block-cloud-metadata
2022-09-21T21:16:01Z [Normal] Started container block-cloud-metadata
2022-09-21T21:16:02Z [Normal] Container image "miykael/nipype_tutorial:latest" already present on machine
2022-09-21T21:16:02Z [Normal] Created container notebook
2022-09-21T21:16:03Z [Normal] Started container notebook
2022-09-21T21:16:04Z [Warning] Back-off restarting failed container

```

How should be error on mount error?

 ![Screenshot 2022-09-22 at 00.21.39](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/0/0a2a90fce2ff8cfbf093927e24500401ac0bc6a5.jpeg)

```auto
 scipy-jhub-values-kind.yaml:

```

```auto
# imagePullSecret is configuration to create a k8s Secret that Helm chart's pods
# can get credentials from to pull their images.
imagePullSecret:
  create: true
  automaticReferenceInjection: true
  registry: docker-registry 
  username: ## <<Change to your User Name>>
  email: ## <<Change to your Email>>
  password: ## <<Change to your Pass>>
hub:
  service:
    type: ClusterIP
  deploymentStrategy:
    type: Recreate
  db:
    type: sqlite-pvc
    upgrade:
    pvc:
      accessModes:
        - ReadWriteOnce
      storage: 3Gi
      storageClassName: standard ## <Change to your Storage Class>
singleuser:
  image:
    name: miykael/nipype_tutorial
    tag: latest
  memory:
    limit: 3G
    guarantee: 2.5G
  defaultUrl: "/lab"
  storage:
    type: dynamic
    extraVolumes:
      - name: local-mount
        hostPath:
          path: /home/myname/neuroml_course_data
    extraVolumeMounts:
      - name: local-mount
        mountPath: /data # where each user can reach the shared data
        readOnly: true

proxy:
  service:
    type: ClusterIP
  secretToken: d292ed1a5f212fb2e31fca0a4a34257932d67c5384150f7d94d1538bfc42b1c8

```

```auto
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
  apiServerAddress: "127.0.0.1"
  apiServerPort: 6443
nodes:
- role: control-plane
- role: worker
  extraMounts:
    - hostPath: /home/myname/neuroml_course_data
      containerPath: /data
- role: worker
  extraMounts:
    - hostPath: /home/myname/neuroml_course_data
      containerPath: /data

```

---

<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:** [September 22, 2022, 2:54pm UTC](https://discourse.jupyter.org/t/mount-local-directory-to-jupyterhub-pods/15890/2 "2022-09-22T14:54:04Z")

</div>

- Does this work if you disable the extra volumes?
- Can you turn on [debug logging](https://zero-to-jupyterhub.readthedocs.io/en/stable/administrator/debug.html#verbose-logging) and show us the hub logs?

---

<div class="post-metadata">

**Author:** ![relyativist](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/relyativist/32/7989_2.png) [@relyativist](https://discourse.jupyter.org/u/relyativist)\
**Post date:** [September 26, 2022, 2:28pm UTC](https://discourse.jupyter.org/t/mount-local-directory-to-jupyterhub-pods/15890/3 "2022-09-26T14:28:57Z")

</div>

Hi @manics,

1. No, I found out it didn’t work without mount, I used `miykael/nipype_tutorial` docker images and there was an error with entrypoint.
2. However, I changed image to `jupyter/scipy-notebook:latest`, now `jupyterhub` is working creating spawning pod, but mounted `/data` directory is empty inside container.
3. I added  
'debug:  
enabled: true  
’  
but can’t see where the should I see extended log?

output of `kubectl describe pod `:

```auto
Volumes:
  volume-myuser:
    Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName: claim-myuser
    ReadOnly: false
  local-mount:
    Type: HostPath (bare host directory volume)
    Path: /home/myuser/neuroml_course_data
    HostPathType:
QoS Class: Burstable
Node-Selectors: <none>
Tolerations: hub.jupyter.org/dedicated=user:NoSchedule
                   hub.jupyter.org_dedicated=user:NoSchedule
                   node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                   node.kubernetes.io/unreachable:NoExecute op=Exists for 300s

```

---

<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:** [September 26, 2022, 9:09pm UTC](https://discourse.jupyter.org/t/mount-local-directory-to-jupyterhub-pods/15890/4 "2022-09-26T21:09:00Z")

</div>

You should be able to fetch the hub logs using `kubectl logs deploy/hub`

How many nodes do you have in your k8s cluster? Host volumes aren’t shared across nodes, so if you’ve copied files to the directory in one node they won’t appear on other nodes.

---

<div class="post-metadata">

**Author:** ![relyativist](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/relyativist/32/7989_2.png) [@relyativist](https://discourse.jupyter.org/u/relyativist)\
**Post date:** [September 27, 2022, 9:17am UTC](https://discourse.jupyter.org/t/mount-local-directory-to-jupyterhub-pods/15890/5 "2022-09-27T09:17:26Z")

</div>

I have created 2 nodes in cluster with kind, according this tutorial [Data Science with Python & JupyterHub on Kubernetes - Part 1 | VMware Tanzu Developer Center](https://tanzu.vmware.com/developer/blog/data-science-with-python-jupyterhub-on-kubernetes-part-1/). But added extraMounts there:

```auto
nodes:
- role: control-plane
- role: worker
  extraMounts:
    - hostPath: /home/yarkin/neuroml_course_data
      containerPath: /data
- role: worker
  extraMounts:
    - hostPath: /home/yarkin/neuroml_course_data
      containerPath: /data

```

Hub-logs with `kubectl logs` of hub:  
[https://drive.google.com/file/d/1cIcA0V00\_975DG9oizmZRY-bbPH35JI5/view?usp=sharing](https://drive.google.com/file/d/1cIcA0V00_975DG9oizmZRY-bbPH35JI5/view?usp=sharing)

Should I create additional volumeclaim to assign access to every spawned pod?

Thanks

---

<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:** [September 27, 2022, 12:49pm UTC](https://discourse.jupyter.org/t/mount-local-directory-to-jupyterhub-pods/15890/6 "2022-09-27T12:49:51Z")

</div>

> [@relyativist](#):
>
> Should I create additional volumeclaim to assign access to every spawned pod?

I’m not sure what you mean by this- could you explain exactly what you’re thinking?

In general I think you’re better off looking for a shared storage solution that works across your nodes, e.g. NFS.

---

<div class="post-metadata">

**Author:** ![relyativist](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/relyativist/32/7989_2.png) [@relyativist](https://discourse.jupyter.org/u/relyativist)\
**Post date:** [September 27, 2022, 1:09pm UTC](https://discourse.jupyter.org/t/mount-local-directory-to-jupyterhub-pods/15890/7 "2022-09-27T13:09:07Z")

</div>

> [@manics](#):
>
> > [@relyativist](#):
> >
> > Should I create additional volumeclaim to assign access to every spawned pod?
> 
> I’m not sure what you mean by this- could you explain exactly what you’re thinking?

Im thinking of adding new `persistantVolumeClaim` to deployment file, from the documentation:

> **[Customizing User Storage](https://z2jh.jupyter.org/en/stable/jupyterhub/customizing/user-storage.html?highlight=persistant)**
>
> For the purposes of this guide, we’ll describe “storage” as a “volume” - a location on a disk where a user’s data resides. Kubernetes handles the creation and allocation of persistent volumes, unde...

Should it do the work?
