Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameter to mount path for notebook PVC #469

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions kubeflow/core/jupyterhub.libsonnet
Expand Up @@ -3,7 +3,7 @@
$.parts(params.namespace).jupyterHubConfigMap(params.jupyterHubAuthenticator, params.disks),
$.parts(params.namespace).jupyterHubService,
$.parts(params.namespace).jupyterHubLoadBalancer(params.jupyterHubServiceType),
$.parts(params.namespace).jupyterHub(params.jupyterHubImage),
$.parts(params.namespace).jupyterHub(params.jupyterHubImage, params.jupyterNotebookPVCMount),
$.parts(params.namespace).jupyterHubRole,
$.parts(params.namespace).jupyterHubServiceAccount,
$.parts(params.namespace).jupyterHubRoleBinding,
Expand Down Expand Up @@ -136,7 +136,7 @@ c.RemoteUserAuthenticator.header_name = 'x-goog-authenticated-user-email'",
},

// image: Image for JupyterHub
jupyterHub(image): {
jupyterHub(image, notebookPVCMount): {
apiVersion: "apps/v1beta1",
kind: "StatefulSet",
metadata: {
Expand Down Expand Up @@ -178,6 +178,12 @@ c.RemoteUserAuthenticator.header_name = 'x-goog-authenticated-user-email'",
containerPort: 8081,
},
],
env: [
{
name: "NOTEBOOK_PVC_MOUNT",
value: notebookPVCMount
},
]
}, // jupyterHub container
],
serviceAccountName: "jupyter-hub",
Expand Down
39 changes: 21 additions & 18 deletions kubeflow/core/jupyterhub_spawner.py
Expand Up @@ -93,21 +93,24 @@ def extra_resource_limits(self):
# TODO(jlewi): Verify this works on minikube.
# TODO(jlewi): Should we set c.KubeSpawner.singleuser_fs_gid = 1000
# see https://github.com/kubeflow/kubeflow/pull/22#issuecomment-350500944
c.KubeSpawner.user_storage_pvc_ensure = True
# How much disk space do we want?
c.KubeSpawner.user_storage_capacity = '10Gi'
c.KubeSpawner.pvc_name_template = 'claim-{username}{servername}'
c.KubeSpawner.volumes = [
{
'name': 'volume-{username}{servername}',
'persistentVolumeClaim': {
'claimName': 'claim-{username}{servername}'
}
}
]
c.KubeSpawner.volume_mounts = [
{
'mountPath': '/home/jovyan/work',
'name': 'volume-{username}{servername}'
}
]
pvc_mount = os.environ.get('NOTEBOOK_PVC_MOUNT')
if pvc_mount:
c.KubeSpawner.user_storage_pvc_ensure = True
# How much disk space do we want?
c.KubeSpawner.user_storage_capacity = '10Gi'
c.KubeSpawner.pvc_name_template = 'claim-{username}{servername}'
c.KubeSpawner.volumes = [
{
'name': 'volume-{username}{servername}',
'persistentVolumeClaim': {
'claimName': 'claim-{username}{servername}'
}
}
]
c.KubeSpawner.volume_mounts = [
{
'mountPath': pvc_mount,
'name': 'volume-{username}{servername}'
}
]

1 change: 1 addition & 0 deletions kubeflow/core/prototypes/all.jsonnet
Expand Up @@ -13,6 +13,7 @@
// @optionalParam jupyterHubServiceType string ClusterIP The service type for Jupyterhub.
// @optionalParam jupyterHubImage string gcr.io/kubeflow/jupyterhub-k8s:1.0.1 The image to use for JupyterHub.
// @optionalParam jupyterHubAuthenticator string null The authenticator to use
// @optionalParam jupyterNotebookPVCMount string /home/jovyan/work Mount path for PVC. Set empty to disable PVC
// @optionalParam reportUsage string false Whether or not to report Kubeflow usage to kubeflow.org.
// @optionalParam usageId string unknown_cluster Optional id to use when reporting usage to kubeflow.org

Expand Down
6 changes: 5 additions & 1 deletion kubeflow/core/tests/jupyterhub_test.jsonnet
Expand Up @@ -104,10 +104,14 @@ std.assertEqual(jupyterhub.parts(params.namespace).jupyterHub(params.jupyterHubI
"containerPort": 8081
}
],
"env": [
"name": "NOTEBOOK_PVC_MOUNT",
"value": "/home/jovyan/work",
]
"volumeMounts": [
{
"mountPath": "/etc/config",
"name": "config-volume"
"name": "config-volume",
}
]
}
Expand Down