This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
docpublic:systemes:systemes:jupyter:jupyterhub [2021/07/10 17:39] adminjp [VirtualEnv] |
docpublic:systemes:systemes:jupyter:jupyterhub [2021/07/12 20:58] (current) adminjp [REMOTE_USER auth] |
||
---|---|---|---|
Line 28: | Line 28: | ||
</ | </ | ||
- | ce package | + | ==== wheel package |
+ | |||
+ | this wheel package is hence installed in /opt | ||
< | < | ||
Line 42: | Line 44: | ||
drwxr-xr-x | drwxr-xr-x | ||
drwxr-xr-x | drwxr-xr-x | ||
+ | </ | ||
+ | |||
+ | ==== upgrade pip ==== | ||
+ | |||
+ | because of this warning | ||
+ | |||
+ | < | ||
+ | You are using pip version 9.0.3, however version 21.1.3 is available. | ||
+ | You should consider upgrading via the 'pip install --upgrade pip' command. | ||
+ | |||
+ | |||
+ | [root@jhub ~]# / | ||
+ | Collecting pip | ||
+ | Downloading https:// | ||
+ | 100% |████████████████████████████████| 1.6MB 755kB/ | ||
+ | Installing collected packages: pip | ||
+ | Found existing installation: | ||
+ | Uninstalling pip-9.0.3: | ||
+ | Successfully uninstalled pip-9.0.3 | ||
+ | Successfully installed pip-21.1.3 | ||
+ | </ | ||
+ | |||
+ | ==== jupyterhub & lab packages ==== | ||
+ | |||
+ | < | ||
+ | [root@jhub ~]# / | ||
+ | Successfully installed Mako-1.1.4 SQLAlchemy-1.4.20 alembic-1.6.5 anyio-3.2.1 babel-2.9.1 certifi-2021.5.30 certipy-0.1.3 chardet-4.0.0 contextvars-2.4 cryptography-3.4.7 dataclasses-0.8 greenlet-1.1.0 idna-2.10 immutables-0.15 json5-0.9.6 jupyter-server-1.9.0 jupyter-telemetry-0.1.0 jupyterhub-1.4.1 jupyterlab-3.0.16 jupyterlab-server-2.6.1 nbclassic-0.3.1 oauthlib-3.1.1 pamela-1.0.0 pyopenssl-20.0.1 python-editor-1.0.4 python-json-logger-2.0.1 pytz-2021.1 requests-2.25.1 requests-unixsocket-0.2.0 ruamel.yaml-0.17.10 ruamel.yaml.clib-0.2.6 sniffio-1.2.0 urllib3-1.26.6 websocket-client-1.1.0 | ||
+ | |||
+ | </ | ||
+ | |||
+ | ==== ipywidgets ==== | ||
+ | |||
+ | then also ipywidgets is installed in /opt because this is needed to allow connection between interactive tools running in the kernel and the user interface. | ||
+ | other python scientific package can be installed in the traditional system paths | ||
+ | |||
+ | < | ||
+ | [root@jhub ~]# / | ||
+ | Successfully installed MarkupSafe-2.0.1 Send2Trash-1.7.1 argon2-cffi-20.1.0 async-generator-1.10 attrs-21.2.0 backcall-0.2.0 bleach-3.3.0 cffi-1.14.6 decorator-5.0.9 defusedxml-0.7.1 entrypoints-0.3 importlib-metadata-4.6.1 ipykernel-5.5.5 ipython-7.16.1 ipython-genutils-0.2.0 ipywidgets-7.6.3 jedi-0.18.0 jinja2-3.0.1 jsonschema-3.2.0 jupyter-client-6.2.0 jupyter-core-4.7.1 jupyterlab-pygments-0.1.2 jupyterlab-widgets-1.0.0 mistune-0.8.4 nbclient-0.5.3 nbconvert-6.0.7 nbformat-5.1.3 nest-asyncio-1.5.1 notebook-6.4.0 packaging-21.0 pandocfilters-1.4.3 parso-0.8.2 pexpect-4.8.0 pickleshare-0.7.5 prometheus-client-0.11.0 prompt-toolkit-3.0.19 ptyprocess-0.7.0 pycparser-2.20 pygments-2.9.0 pyparsing-2.4.7 pyrsistent-0.18.0 python-dateutil-2.8.1 pyzmq-22.1.0 six-1.16.0 terminado-0.10.1 testpath-0.5.0 tornado-6.1 traitlets-4.3.3 typing-extensions-3.10.0.0 wcwidth-0.2.5 webencodings-0.5.1 widgetsnbextension-3.5.1 zipp-3.5.0 | ||
+ | </ | ||
+ | |||
+ | ===== nodejs npm ===== | ||
+ | |||
+ | JupyterHub also currently defaults to requiring configurable-http-proxy, | ||
+ | |||
+ | < | ||
+ | [root@jhub ~]# dnf install nodejs npm | ||
+ | Installé: | ||
+ | nodejs-1: | ||
+ | </ | ||
+ | |||
+ | ==== JupyterHub Configuration ==== | ||
+ | |||
+ | Create directory for jupyterhub config file and cd into it, | ||
+ | |||
+ | < | ||
+ | [root@jhub ~]# mkdir -p / | ||
+ | [root@jhub ~]# cd / | ||
+ | </ | ||
+ | |||
+ | Then generate the default configuration file | ||
+ | |||
+ | < | ||
+ | [root@jhub jupyterhub]# | ||
+ | Writing default config to: jupyterhub_config.py | ||
+ | </ | ||
+ | |||
+ | The generated jupyterhub_config.py file is nearly 1000 lines of commented configuration options. We will only change 1 line at this point, setting the default " | ||
+ | |||
+ | Edit jupyterhub_config.py, | ||
+ | |||
+ | You will need to edit the configuration file to make the JupyterLab interface by the default. Set the following configuration option in your jupyterhub_config.py file: | ||
+ | |||
+ | < | ||
+ | # - You can set this to `/lab` to have JupyterLab start by default, rather than Jupyter Notebook. | ||
+ | # | ||
+ | c.Spawner.default_url = '/ | ||
+ | </ | ||
+ | |||
+ | Further configuration options may be found in the documentation. | ||
+ | |||
+ | ==== systemd startup ==== | ||
+ | |||
+ | Create a systemd " | ||
+ | |||
+ | < | ||
+ | [root@jhub jupyterhub]# | ||
+ | </ | ||
+ | |||
+ | edit the Unit file / | ||
+ | |||
+ | < | ||
+ | [root@jhub jupyterhub]# | ||
+ | [Unit] | ||
+ | |||
+ | Description=JupyterHub | ||
+ | After=syslog.target network.target | ||
+ | |||
+ | [Service] | ||
+ | |||
+ | User=root | ||
+ | Environment=" | ||
+ | ExecStart=/ | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | </ | ||
+ | |||
+ | Now link that file to the directory with the system' | ||
+ | |||
+ | < | ||
+ | [root@jhub systemd]# | ||
+ | [root@jhub systemd]# | ||
+ | lrwxrwxrwx 1 root root 67 10 juil. 22:07 / | ||
+ | </ | ||
+ | |||
+ | Then tell systemd to reload its configuration files so that it knows about that new jupyterhub.service | ||
+ | |||
+ | < | ||
+ | [root@jpthub systemd]# | ||
+ | </ | ||
+ | |||
+ | start it and enable it at boot | ||
+ | |||
+ | < | ||
+ | [root@jhub systemd]# | ||
+ | [root@jhub systemd]# | ||
+ | ● jupyterhub.service - JupyterHub | ||
+ | | ||
+ | | ||
+ | |||
+ | [root@jhub systemd]# | ||
+ | Created symlink / | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | ==== firewall ==== | ||
+ | |||
+ | open jupyterhub webservice to our local ip network | ||
+ | |||
+ | < | ||
+ | [root@jhub systemd]# | ||
+ | success | ||
+ | [root@jhub systemd]# | ||
+ | success | ||
+ | </ | ||
+ | |||
+ | ==== jupyterhub webservice ==== | ||
+ | |||
+ | now the jupyterhub webservice is available at http:// | ||
+ | |||
+ | ===== https and reverse proxy with apache ===== | ||
+ | |||
+ | * https:// | ||
+ | |||
+ | change the // c.JupyterHub.bind_url// | ||
+ | |||
+ | < | ||
+ | [root@jhub jupyterhub]# | ||
+ | # | ||
+ | c.JupyterHub.bind_url = ' | ||
+ | </ | ||
+ | |||
+ | ==== apache ==== | ||
+ | |||
+ | install httpd and mod_ssl package | ||
+ | |||
+ | < | ||
+ | [root@jhub certs]# yum install httpd mod_ssl | ||
+ | </ | ||
+ | |||
+ | jupyterhub vhost configuration | ||
+ | |||
+ | < | ||
+ | [root@jhub certs]# cat / | ||
+ | |||
+ | # redirect HTTP to HTTPS | ||
+ | Listen 80 | ||
+ | < | ||
+ | ServerName jhub.domain.fr | ||
+ | Redirect / https:// | ||
+ | </ | ||
+ | |||
+ | Listen 443 | ||
+ | < | ||
+ | |||
+ | ServerName jhub.domain.fr | ||
+ | |||
+ | # configure SSL | ||
+ | SSLEngine on | ||
+ | SSLCertificateFile / | ||
+ | SSLCertificateKeyFile / | ||
+ | SSLProtocol All -SSLv2 -SSLv3 | ||
+ | # SSLOpenSSLConfCmd DHParameters / | ||
+ | SSLCipherSuite EECDH+AESGCM: | ||
+ | |||
+ | # Use RewriteEngine to handle websocket connection upgrades | ||
+ | RewriteEngine On | ||
+ | RewriteCond %{HTTP: | ||
+ | RewriteCond %{HTTP: | ||
+ | RewriteRule /(.*) ws:// | ||
+ | |||
+ | < | ||
+ | # preserve Host header to avoid cross-origin problems | ||
+ | ProxyPreserveHost on | ||
+ | # proxy to JupyterHub | ||
+ | ProxyPass | ||
+ | ProxyPassReverse | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ==== firewall ==== | ||
+ | |||
+ | open https service in the firewall to our IP subnet | ||
+ | |||
+ | < | ||
+ | [root@jpthub certs]# firewall-cmd --permanent --add-rich-rule 'rule family=" | ||
+ | success | ||
+ | [root@jpthub certs]# firewall-cmd --reload | ||
+ | success | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== SAML authenticator ===== | ||
+ | |||
+ | * https:// | ||
+ | * https:// | ||
+ | |||
+ | |||
+ | < | ||
+ | [root@jhub jupyterhub]# | ||
+ | Collecting jupyterhub-samlauthenticator | ||
+ | Downloading jupyterhub_samlauthenticator-0.0.9-py3-none-any.whl (17 kB) | ||
+ | Requirement already satisfied: jupyterhub> | ||
+ | ... | ||
+ | Installing collected packages: pyopenssl, future, lxml, eight, signxml, jupyterhub-samlauthenticator | ||
+ | Attempting uninstall: pyopenssl | ||
+ | Found existing installation: | ||
+ | Uninstalling pyOpenSSL-20.0.1: | ||
+ | Successfully uninstalled pyOpenSSL-20.0.1 | ||
+ | Successfully installed eight-1.0.1 future-0.18.2 jupyterhub-samlauthenticator-0.0.9 lxml-4.6.3 pyopenssl-19.1.0 signxml-2.8.2 | ||
+ | </ | ||
+ | |||
+ | it installed those directories/ | ||
+ | |||
+ | < | ||
+ | [root@jhub jupyterhub]# | ||
+ | total 44 | ||
+ | -rw-r--r-- 1 root root 36101 12 juil. 16:33 samlauthenticator.py | ||
+ | -rw-r--r-- 1 root root 1144 12 juil. 16:33 __init__.py | ||
+ | drwxr-xr-x 2 root root 4096 12 juil. 16:33 __pycache__ | ||
+ | [root@jhub jupyterhub]# | ||
+ | total 40 | ||
+ | -rw-r--r-- 1 root root 1085 12 juil. 16:33 LICENSE.txt | ||
+ | -rw-r--r-- 1 root root 92 12 juil. 16:33 WHEEL | ||
+ | -rw-r--r-- 1 root root 18 12 juil. 16:33 top_level.txt | ||
+ | -rw-r--r-- 1 root root 17256 12 juil. 16:33 METADATA | ||
+ | -rw-r--r-- 1 root root 0 12 juil. 16:33 REQUESTED | ||
+ | -rw-r--r-- 1 root root 4 12 juil. 16:33 INSTALLER | ||
+ | -rw-r--r-- 1 root root 1026 12 juil. 16:33 RECORD | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== REMOTE_USER auth ===== | ||
+ | |||
+ | we'll try to authenticate through a shibboleth SP proxy to benefit from federated access , then redirect that REMOTE_USER to jupyterhub | ||
+ | |||
+ | * https:// | ||
+ | |||
+ | < | ||
+ | [root@jhub jupyterhub]# | ||
+ | Collecting jhub_remote_user_authenticator | ||
+ | Downloading jhub_remote_user_authenticator-0.1.0-py3-none-any.whl (3.6 kB) | ||
+ | ... | ||
+ | Installing collected packages: jhub-remote-user-authenticator | ||
+ | Successfully installed jhub-remote-user-authenticator-0.1.0 | ||
+ | |||
</ | </ |