-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjupyterhub_config.py
122 lines (92 loc) · 3.86 KB
/
jupyterhub_config.py
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
# import base spawner & authenticator classes
from csystemdspawner import CSystemdSpawner
from jupyterhub.auth import PAMAuthenticator
import hashlib # for `md5`
import os, sys, pwd
# ##############################################################################
# Jupyterhub Config File
c.JupyterHub.log_level = 10
# base application config
c.JupyterHub.hub_ip = '192.168.2.6'
c.JupyterHub.hub_port = 9001
c.JupyterHub.cleanup_servers = False
c.JupyterHub.active_server_limit = 70
c.JupyterHub.concurrent_spawn_limit = 100
# named servers
c.JupyterHub.allow_named_servers = True
c.JupyterHub.named_server_limit_per_user = 1
c.JupyterHub.default_server_name = 'cat'
# whether admins can access all notebook servers
c.JupyterHub.admin_access = True
# file locations
c.JupyterHub.cookie_secret_file = '/var/lib/jupyterhub/cookie_secret'
c.JupyterHub.db_url = 'sqlite:////var/lib/jupyterhub/db.sqlite'
c.JupyterHub.data_files_path = '/opt/shared/share/jupyterhub'
## XXX: external https now being handled by nginx
#c.JupyterHub.ssl_key = ...
#c.JupyterHub.ssl_cert = ...
# internal ssl
c.JupyterHub.internal_ssl = False
c.JupyterHub.generate_certs = False
c.JupyterHub.internal_certs_location = '/var/lib/jupyterhub/internal-ssl/'
## set spawner & authenticator classes
c.JupyterHub.spawner_class = CSystemdSpawner
c.JupyterHub.authenticator_class = PAMAuthenticator
## services
c.JupyterHub.services = [
{
'name': 'cull-idle',
'admin': True,
'command': [sys.executable,
'/opt/shared/bin/cull_idle_servers.py',
'--timeout=5400'],
}
]
## HTTP Route Proxy ############################################################
# proxy config
#c.ConfigurableHTTPProxy.pid_file = "/var/lib/jupyterhub/jupyterhub-proxy.pid"
#c.ConfigurableHTTPProxy.debug = True
# XXX: routing proxy moved to it's own service
c.ConfigurableHTTPProxy.should_start = False
c.ConfigurableHTTPProxy.auth_token = "testing" # passed to proxy as CONFIGPROXY_AUTH_TOKEN
c.ConfigurableHTTPProxy.api_url = 'http://127.0.0.1:9000'
## Authentication ##############################################################
# basic PAM authentication setup
c.PAMAuthenticator.open_sessions = True # (actually log them in, not just auth.)
c.PAMAuthenticator.whitelist = set()
c.PAMAuthenticator.blacklist = {'admin', 'root'}
c.PAMAuthenticator.group_whitelist = {'hub-admin',
'users'}
c.PAMAuthenticator.admin_groups = {'hub-admin'}
c.PAMAuthenticator.service = 'jupyter-hub'
## Server Spawning ############################################################
c.CSystemdSpawner.name = ''
c.CSystemdSpawner.controller = 'beta'
c.CSystemdSpawner.host = '192.168.2.7'
c.CSystemdSpawner.unit_name_template = 'notebook-{USERID}-{NAME_HASH}'
c.CSystemdSpawner.cmd = [ # command spawning server
'/opt/shared/bin/platform-python', '-m', 'jupyterhub.singleuser' ]
# env config
c.CSystemdSpawner.default_shell = '/bin/bash'
c.CSystemdSpawner.environment = { 'PATH': '/opt/shared/bin:/bin:/bin:/usr/bin:/sbin:/usr/sbin',
'PYTHONUNBUFFERED': '1' }
# user-service config
c.CSystemdSpawner.user_workingdir = '/tmp/'
# main resource container/slice
c.CSystemdSpawner.slice = 'jupyter'
# (NOTE: using a specific systemd-slice allows us to limit ram+swap usage
# see github.com/jupyterhub/systemdspawner/issues/15#issuecomment-327947945
# however, this only works for >= RHEL/Cent 8.0)
c.CSystemdSpawner.mem_limit = '1G'
c.CSystemdSpawner.cpu_limit = 0.5
c.CSystemdSpawner.isolate_devices = False
c.CSystemdSpawner.isolate_tmp = True
c.CSystemdSpawner.disable_user_sudo = True
c.CSystemdSpawner.unit_extra_properties = {
'MemoryAccounting' : 'true',
'CPUAccounting' : 'true',
'MemoryMax' : '1G',
'MemorySwapMax' : '1G',
'CPUQuota' : '50%'
# 'CPUQuotaPeriodSec' : '500'
}