Tim - good idea. I’ll try to write up our experience later.
Another NFS specific hack that proved useful is related to NFS shared folders. We wanted teaching assistants and instructors to be able to share e.g. nbgrader databases.
To do this, we used the stanza shown below by adding it to in hub::extraConfig. The configuration file is a JSON file stored on the hub (in same PV as hub sqlite database). The format is e.g.
{
“csci2400” : [ “grunwald”, “jipa4409” ],
“nbgrader” : [ “grunwald” ]
}
The code that modifies the pod specification on launch is in the stanza below.
kubevol: |
from kubernetes import client
from kubespawner.utils import get_k8s_model
from kubernetes.client.models import ( V1Volume, V1VolumeMount )
import json
def modify_pod_hook(spawner, pod):
try:
with open('/srv/jupyterhub/shared-mounts.json') as json_data:
sharedVols = json.load(json_data)
user=spawner.user.name
for mnt in sharedVols:
if user in sharedVols[mnt]:
pod.spec.volumes.append(
get_k8s_model(V1Volume,
{ 'name' : mnt,
'hostPath': { 'path' : "/home/data/shared/" + mnt,
'type' : 'DirectoryOrCreate' }
} )
)
# Note implicitly only 1 container...
pod.spec.containers[0].volume_mounts.append(
get_k8s_model(V1VolumeMount,
{ 'name' : mnt, 'mountPath' : '/shared/' + mnt } )
)
except Exception as e:
spawner.log.info("Exception in shared-mounts" + str(e))
pass
return pod
c.KubeSpawner.modify_pod_hook = modify_pod_hook