From a33f1d7d326d869cd950fe92cbb3fc0992510952 Mon Sep 17 00:00:00 2001 From: Georgiana Dolocan Date: Fri, 21 Jul 2023 11:06:41 +0300 Subject: [PATCH 01/13] Copy hub image into a new hub-experimental image and configure chartpress to push it on quay --- helm-charts/chartpress.yaml | 4 +++ .../images/hub-experimental/Dockerfile | 25 +++++++++++++++++++ .../jupyterhub_configurator_config.py | 15 +++++++++++ .../images/hub-experimental/requirements.txt | 1 + 4 files changed, 45 insertions(+) create mode 100644 helm-charts/images/hub-experimental/Dockerfile create mode 100644 helm-charts/images/hub-experimental/jupyterhub_configurator_config.py create mode 100644 helm-charts/images/hub-experimental/requirements.txt diff --git a/helm-charts/chartpress.yaml b/helm-charts/chartpress.yaml index 1dfc4d962c..9aa9a74aee 100644 --- a/helm-charts/chartpress.yaml +++ b/helm-charts/chartpress.yaml @@ -4,3 +4,7 @@ charts: images: hub: valuesPath: jupyterhub.hub.image + - name: basehub + images: + hub-experimental: + imageName: quay.io/2i2c/experimental-hub diff --git a/helm-charts/images/hub-experimental/Dockerfile b/helm-charts/images/hub-experimental/Dockerfile new file mode 100644 index 0000000000..548646c8d9 --- /dev/null +++ b/helm-charts/images/hub-experimental/Dockerfile @@ -0,0 +1,25 @@ +# This image tag should match the dependent JupyterHub Helm chart's version as +# declared in basehub/Chart.yaml. +# +# If you make an update to this tag and the JupyterHub Helm chart's version, +# then first commit those changes. +# Then, from the `helm-charts` directory where the `chartpress.yaml` is located, +# perform `chartpress --push` with your quay.io container registry credentials +# configured to have access to https://quay.io/repository/2i2c/pilot-hub. +# +# Note: if on macOs with M1, you need to run chartpress with docker buildx under the hood and specify +# the architecture to use. +# `chartpress --push --builder docker-buildx --platform linux/amd64` +# Ref: https://cloudolife.com/2022/03/05/Infrastructure-as-Code-IaC/Container/Docker/Docker-buildx-support-multiple-architectures-images/ +# +FROM jupyterhub/k8s-hub:3.0.0-beta.1 + +COPY requirements.txt /tmp/ + +RUN pip install -r /tmp/requirements.txt + +USER root +RUN mkdir -p /usr/local/etc/jupyterhub-configurator + +COPY jupyterhub_configurator_config.py /usr/local/etc/jupyterhub-configurator/jupyterhub_configurator_config.py +USER $NB_USER diff --git a/helm-charts/images/hub-experimental/jupyterhub_configurator_config.py b/helm-charts/images/hub-experimental/jupyterhub_configurator_config.py new file mode 100644 index 0000000000..67a79a7f0c --- /dev/null +++ b/helm-charts/images/hub-experimental/jupyterhub_configurator_config.py @@ -0,0 +1,15 @@ +import json +import os +from glob import glob + +CONFIGURATOR_BASE_PATH = "/usr/local/etc/jupyterhub-configurator" + +schema_files = sorted(glob(os.path.join(CONFIGURATOR_BASE_PATH, "*.schema.json"))) + +schemas = {} + +for sf in schema_files: + with open(sf) as f: + schemas[sf] = json.load(f) + +c.Configurator.schemas = schemas diff --git a/helm-charts/images/hub-experimental/requirements.txt b/helm-charts/images/hub-experimental/requirements.txt new file mode 100644 index 0000000000..4f895cace0 --- /dev/null +++ b/helm-charts/images/hub-experimental/requirements.txt @@ -0,0 +1 @@ +git+https://github.com/yuvipanda/jupyterhub-configurator@ed7e3a0df1e3d625d10903ef7d7fd9c2fbb548db From cc286c584cf64d958e80667202a1f7267246fc58 Mon Sep 17 00:00:00 2001 From: Georgiana Dolocan Date: Fri, 21 Jul 2023 11:50:26 +0300 Subject: [PATCH 02/13] Bring latest kubespawner in the hub-experimental image --- helm-charts/images/hub-experimental/requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/helm-charts/images/hub-experimental/requirements.txt b/helm-charts/images/hub-experimental/requirements.txt index 4f895cace0..2186d5ee7f 100644 --- a/helm-charts/images/hub-experimental/requirements.txt +++ b/helm-charts/images/hub-experimental/requirements.txt @@ -1 +1,3 @@ git+https://github.com/yuvipanda/jupyterhub-configurator@ed7e3a0df1e3d625d10903ef7d7fd9c2fbb548db +# Brings on using `unlisted_choice` in profile options per https://github.com/2i2c-org/infrastructure/issues/2146 +git+https://github.com/jupyterhub/kubespawner@def501f1d60b8e5629745acb0bcc45b151b1decc From 9a54d426b8b42ebb0d280ab6dd9abf15e53d8449 Mon Sep 17 00:00:00 2001 From: Georgiana Dolocan Date: Fri, 21 Jul 2023 12:04:02 +0300 Subject: [PATCH 03/13] Use hub-experimental image for leap and enable unlisted_image_choice for each of the profiles --- config/clusters/leap/common.values.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config/clusters/leap/common.values.yaml b/config/clusters/leap/common.values.yaml index 896150e453..a5f27d6637 100644 --- a/config/clusters/leap/common.values.yaml +++ b/config/clusters/leap/common.values.yaml @@ -37,6 +37,9 @@ basehub: name: LEAP url: https://leap-stc.github.io hub: + image: + name: quay.io/2i2c/experimental-hub + tag: "0.0.1-0.dev.git.6406.hc1091b1c" allowNamedServers: true config: Authenticator: @@ -189,6 +192,11 @@ basehub: cpu_limit: 16 image: &profile_list_profile_options_image display_name: Image + unlisted_choice: + enabled: True + display_name: "Custom org/image:tag" + kubespawner_override: + image: "{value}" choices: pangeo_new: display_name: Base Pangeo Notebook ("2023.05.18") @@ -268,6 +276,11 @@ basehub: profile_options: image: display_name: Image + unlisted_choice: + enabled: True + display_name: "Custom org/image:tag" + kubespawner_override: + image: "{value}" choices: tensorflow_new: display_name: Pangeo Tensorflow ML Notebook ("2023.05.18") From b0ac7af9f7b4514980574839d80934b7cda350da Mon Sep 17 00:00:00 2001 From: Georgiana Dolocan Date: Fri, 21 Jul 2023 20:00:26 +0300 Subject: [PATCH 04/13] Add regex --- config/clusters/leap/common.values.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/config/clusters/leap/common.values.yaml b/config/clusters/leap/common.values.yaml index a5f27d6637..f187f5f45e 100644 --- a/config/clusters/leap/common.values.yaml +++ b/config/clusters/leap/common.values.yaml @@ -194,7 +194,9 @@ basehub: display_name: Image unlisted_choice: enabled: True - display_name: "Custom org/image:tag" + display_name: "Custom image" + validation_regex: "^.+:.+$" + validation_message: "Must be an image location, matching ^.+:.+$" kubespawner_override: image: "{value}" choices: @@ -278,7 +280,9 @@ basehub: display_name: Image unlisted_choice: enabled: True - display_name: "Custom org/image:tag" + display_name: "Custom image" + validation_regex: "^.+:.+$" + validation_message: "Must be an image location, matching ^.+:.+$" kubespawner_override: image: "{value}" choices: From d5592def722d0935b5773242dbf46920153e01c2 Mon Sep 17 00:00:00 2001 From: Georgiana Dolocan Date: Mon, 24 Jul 2023 14:47:30 +0300 Subject: [PATCH 05/13] Add custom suer profile choice --- .../features/custom-user-profile-choice.md | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 docs/howto/features/custom-user-profile-choice.md diff --git a/docs/howto/features/custom-user-profile-choice.md b/docs/howto/features/custom-user-profile-choice.md new file mode 100644 index 0000000000..b0339fc756 --- /dev/null +++ b/docs/howto/features/custom-user-profile-choice.md @@ -0,0 +1,34 @@ +# Allow users to setup custom, free-form user profile choices + +Sometimes it is useful to allow users to specify their own, free-form choice for an option. +We can make this possible by enabling and configuring [`KubeSpawner.profile_list..profile_options.