Skip to content

Commit 62638b4

Browse files
committed
added initial jupyterhub sections
1 parent b850bd5 commit 62638b4

File tree

2 files changed

+89
-14
lines changed

2 files changed

+89
-14
lines changed
-58.3 KB
Binary file not shown.

modules/tutorials/pages/jupyterhub.adoc

Lines changed: 89 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@
22
:description: A tutorial on how to configure various aspects of JupyterHub on Kubernetes.
33
:keywords: notebook, JupyterHub, Kubernetes, k8s, Spark, HDFS, S3
44

5-
.Drop-down example
6-
[%collapsible]
7-
====
8-
xxx:
9-
10-
[source,console]
11-
----
12-
xxx
13-
----
14-
====
15-
165
This tutorial illustrates various scenarios and configuration options when using JupyterHub on Kubernetes.
176
The custom resources and configuration settings that are discussed here are based on the JupyterHub-Keycloak demo, so you may find it helpful to have that demo running to reference things as you read through this tutorial.
187

@@ -55,7 +44,7 @@ The keycloak and jupyterhub endpoints are defined in the jupyter hub chart value
5544
This can be achieved by having the keycloak deployment write out its co-ordinates into a ConfigMap during start-up, which can then be referenced by the JupyterHub chart like this:
5645
5746
[source,yaml]
58-
---
47+
----
5948
options:
6049
hub:
6150
config:
@@ -94,8 +83,11 @@ options:
9483
9584
=== Discovery
9685
97-
As mentioned above, keycloak writes out it endpoint information to ConfigMap, like this:
86+
As mentioned above, keycloak writes out its endpoint information to a ConfigMap, shown in the code section below.
9887
88+
.Writing the ConfigMap
89+
[%collapsible]
90+
====
9991
[source,yaml]
10092
----
10193
---
@@ -140,6 +132,8 @@ kind: Deployment
140132
wait
141133
done
142134
----
135+
====
136+
143137
144138
=== Security
145139
@@ -255,12 +249,16 @@ options:
255249
...
256250
----
257251
252+
image::../images/jupyterhub/sign-up.png[Create a user]
253+
258254
Users must either be included in an `allowed_users` list, or the property `allow_all` must be set to `true`.
259255
The creation of new users will be checked against these settings and refused if appropriate.
260256
If an admin_users property is defined, then associated users will see an additional tab on the JupyterHub home screen, allowing them to carry out user management actions (e.g. create user groups and assign users to them, assign users to the admin role, delete users).
261257
258+
image::../images/jupyterhub/admin-user.png[Admin tab]
259+
262260
NOTE: The above applies to version 4.x of the JupyterHub Helm chart.
263-
Version 3.x does not impose these limitations and users can be added and used without any constraints.
261+
Version 3.x does not impose these limitations and users can be added and used without specifying `allowed_users` or `allow_all`.
264262
265263
==== OAuth Authenticator (Keycloak)
266264
@@ -273,8 +271,85 @@ To authenticate against a Keycloak instance it is necessary to provide the follo
273271
274272
=== GenericOAuthenticator
275273
274+
This section of the JupyterHub values specifies that we are using GenericOAuthenticator for our authentication.
275+
276+
[source,yaml]
277+
----
278+
...
279+
hub:
280+
config:
281+
Authenticator:
282+
# don't filter here: delegate to Keycloak
283+
allow_all: true # <1>
284+
admin_users:
285+
- isla.williams # <2>
286+
GenericOAuthenticator:
287+
client_id: jupyterhub
288+
client_secret: ...
289+
username_claim: preferred_username
290+
scope:
291+
- openid # <3>
292+
JupyterHub:
293+
authenticator_class: generic-oauth # <4>
294+
...
295+
----
296+
297+
<1> We need to either provide a list of users using `allowed_users`, or to explicitly allow _all_ users, as done here.
298+
We will delegate this to Keycloak so that we do not have to maintain users in two places.
299+
<2> Each admin user will have access to an "Admin" tab on the JupyterHub UI where certain user-management actions can be carried out.
300+
<3> Define the Keycloak scope
301+
<4> Specifies which authenticator class to use
302+
303+
The endpoints can be defined directly under `GenericOAuthenticator` as well, though for our purposes we will set them in a configuration script (see below).
304+
276305
=== Certificates
277306
307+
The demo uses a self-signed certificate that needs to be accepted by JupyterHub.
308+
This involves:
309+
310+
* mounting a secret created with the same secret class as used for the self-signed certificate used by Keycloak
311+
* make this secret available to JupyterHub
312+
* it may also be necessary to point python at this specific certificate
313+
314+
This can be seen below:
315+
316+
[source,yaml]
317+
----
318+
extraEnv: # <1>
319+
CACERT: /etc/ssl/certs/ca-certificates.crt
320+
CERT: /etc/ssl/certs/ca-certificates.crt
321+
CURLOPT_CAINFO: /etc/ssl/certs/ca-certificates.crt
322+
...
323+
extraVolumes:
324+
- name: tls-ca-cert # <2>
325+
ephemeral:
326+
volumeClaimTemplate:
327+
metadata:
328+
annotations:
329+
secrets.stackable.tech/class: tls
330+
spec:
331+
storageClassName: secrets.stackable.tech
332+
accessModes:
333+
- ReadWriteOnce
334+
resources:
335+
requests:
336+
storage: "1"
337+
extraVolumeMounts:
338+
- name: tls-ca-cert
339+
# Alternative: mount to another filename in this folder and call update-ca-certificates
340+
mountPath: /etc/ssl/certs/ca-certificates.crt # <3>
341+
subPath: ca.crt
342+
- name: tls-ca-cert
343+
mountPath: /usr/local/lib/python3.12/site-packages/certifi/cacert.pem # <4>
344+
subPath: ca.crt
345+
----
346+
347+
<1> Specify which certificate(s) should be used internally (in the code above this is using the default certificate, but is included for the sake of completion)
348+
<2> Create the certificate with the same secret class (`tls`) as Keycloak
349+
<3> Mount this certificate.
350+
If the default file is not overwritten, but is mounted to a new file in the same directory, then the certificates should be updated by calling e.g. `update-ca-certificates`.
351+
<4> ensure python is using the same certificate.
352+
278353
=== Endpoints
279354
280355
=== Driver Service

0 commit comments

Comments
 (0)