/
persistent_storage.yaml
78 lines (72 loc) · 2.85 KB
/
persistent_storage.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
binderhub:
nodeSelector:
base: worker
config:
BinderHub:
base_url: /services/binder/
extraEnv:
# NOTE: when you change limit, update hub.templateVars.projects_limit too
- name: PROJECTS_LIMIT_PER_USER
value: "5"
extraConfig:
00-launcher: |
from tornado import web
import json
import os
async def check_user_projects(launcher, image, username, server_name, repo_url):
# we are making request to API with admin token
resp = await launcher.api_request(
'projects/%s' % username,
method='GET',
)
body = json.loads(resp.body.decode('utf-8'))
projects = body['projects']
projects_limit = int(os.getenv('PROJECTS_LIMIT_PER_USER', 0))
if projects_limit > 0 and projects:
projects_repo_list = [p[0] for p in projects]
if repo_url not in projects_repo_list and len(projects) >= projects_limit:
raise web.HTTPError(409, "No more than {} projects is allowed. "
"One must be deleted before a new project can be created.".format(projects_limit))
c.Launcher.pre_launch_hook = check_user_projects
jupyterhub:
hub:
templateVars:
projects_limit: "5"
extraVolumes:
- name: hub-templates
configMap:
name: hub-templates
- name: hub-extra-config
configMap:
name: hub-extra-config
extraVolumeMounts:
- name: hub-templates
mountPath: /etc/jupyterhub/templates
- mountPath: /etc/jupyterhub/extra_config.py # mount where jupyterhub_config.py is, we import it there.
subPath: extra_config.py
name: hub-extra-config
services:
binder:
url: http://194.95.75.9:30193 # base worker
oauth_redirect_uri: "https://notebooks-test.gesis.org/services/binder/oauth_callback"
oauth_no_confirm: true
templatePaths:
- "/etc/jupyterhub/templates"
extraConfig:
# set pod restart_policy back to default value OnFailure
02-never-restart: |
c.KubeSpawner.extra_pod_config.update({'restart_policy': 'OnFailure'})
00-binder: |
from extra_config import PersistentBinderSpawner, ProjectAPIHandler
c.JupyterHub.spawner_class = PersistentBinderSpawner
c.JupyterHub.extra_handlers = [(r'/api/projects/([^/]+)', ProjectAPIHandler), ]
singleuser:
events: true # events_enabled - to get events from kubespawner
storage:
type: dynamic
capacity: 5Gi
image:
# https://github.com/gesiscss/data_science_image
# NOTE: when you update this image, don't forget to update `default_project` attribute of `BinderSpawner` in extra_config.py
name: gesiscss/singleuser-orc
tag: "r2d-dd93b3e"