/
values.yaml
149 lines (139 loc) · 5.61 KB
/
values.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
binderhub:
# Helm config for BinderHub goes here
# see https://github.com/jupyterhub/binderhub/blob/master/helm-chart/binderhub/values.yaml
# pdb:
# minAvailable: 0
# NOTE: binder pod must have 1 replica,
# otherwise there are authentication errors
# (https://github.com/jupyterhub/jupyterhub/issues/2841)
replicas: 1
config:
BinderHub:
auth_enabled: true
# NOTE: when base_url is changed,
# change also binder_base_url and static_binder in jupyterhub.hub.extraConfig.20-template-variables
base_url: /services/binder/
use_registry: true
build_image: quay.io/jupyterhub/repo2docker:2021.08.0-136.g47ea95a
cors_allow_origin: "*"
extraEnv:
- name: PROJECTS_LIMIT_PER_USER
value: "5"
extraConfig:
20-launcher: |
import json
import os
from tornado import web
async def check_user_projects(launcher, image, username, server_name, repo_url):
"""Checks if current user exceeds the limit of projects stored per user or not.
If yes, show an error message to user.
"""
projects_limit = int(os.getenv('PROJECTS_LIMIT_PER_USER', 0))
if projects_limit > 0:
# 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']
if projects:
projects_repo_list = [p['repo_url'] 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:
# Helm config for JupyterHub goes here
# see https://github.com/jupyterhub/zero-to-jupyterhub-k8s/blob/master/jupyterhub/values.yaml
custom:
binderauth_enabled: true
mount_all_projects: true
default_project:
repo_url: "https://github.com/gesiscss/persistent_binderhub"
ref: "0.2.0-n919"
cull:
# don't cull authenticated users
users: False
hub:
# NOTE: hub and proxy must have 1 pod
# (https://github.com/jupyterhub/jupyterhub/issues/2841#issuecomment-561848594)
# replicas: 1
pdb:
minAvailable: 0
extraVolumes:
- name: persistent-bhub-templates
configMap:
name: persistent-bhub-templates
- name: persistent-bhub-statics
configMap:
name: persistent-bhub-statics
- name: persistent-bhub-config
configMap:
name: persistent-bhub-config
extraVolumeMounts:
- name: persistent-bhub-templates
mountPath: /etc/jupyterhub/templates
- name: persistent-bhub-statics
# mount to where jupyterhub static files are
mountPath: /usr/local/share/jupyterhub/static/persistent_bhub
- name: persistent-bhub-config
# mount to where jupyterhub_config.py is,
# we import the spawner class from persistent_bhub_config inside jupyterhub_config.py (hub.extraConfig)
mountPath: /usr/local/etc/jupyterhub/persistent_bhub_config.py
subPath: persistent_bhub_config.py
templatePaths:
- "/etc/jupyterhub/templates"
templateVars:
persistency_explanation: "Have a Binder-Ready repository? With Persistent BinderHub, turn this repository into a persistent Jupyter environment, allowing you to continue your analysis from anywhere at any time."
#shutdownOnLogout: true
#authenticatePrometheus: false
redirectToServer: false
services:
binder:
oauth_no_confirm: true
oauth_client_id: "binder-oauth-client-test"
config:
JupyterHub:
authenticator_class: dummy
extraConfig:
20-template-variables: |
import random
c.JupyterHub.template_vars.update({
"binder_base_url": "/services/binder/",
"static_binder": "/services/binder/static/",
"static_version": hex(random.getrandbits(128))[2:],
})
10-project-api: |
from persistent_bhub_config import ProjectAPIHandler
c.JupyterHub.extra_handlers = [(r'/api/projects/([^/]+)', ProjectAPIHandler)]
# restart_policy is already set 'OnFailure' by kubespawner:
# https://github.com/jupyterhub/kubespawner/blob/8751773916ccc6b84c998f7950dd3e07fea5ae4e/kubespawner/objects.py#L231
# c.KubeSpawner.extra_pod_config.update({'restart_policy': 'OnFailure'})
00-binder: |
from persistent_bhub_config import PersistentBinderSpawner
c.JupyterHub.spawner_class = PersistentBinderSpawner
proxy:
chp:
pdb:
minAvailable: 0
singleuser:
# events_enabled - to get events from kubespawner
events: true
# to make notebook servers aware of hub
cmd: jupyterhub-singleuser
storage:
type: dynamic
capacity: 10Gi
# this is not used, default_project is used instead
image:
name: null
tag: null
# https://zero-to-jupyterhub.readthedocs.io/en/latest/administrator/optimization.html#pulling-images-before-users-arrive
# we dont need this, because default project must be always built at first
prePuller:
hook:
enabled: false
continuous:
enabled: false