Skip to content

Commit

Permalink
Merge pull request #2885 from GeorgianaElena/multiple-hub-image-exper…
Browse files Browse the repository at this point in the history
…iments

Allow multiple hub image experiments
  • Loading branch information
GeorgianaElena authored Jul 31, 2023
2 parents 8a8f6c4 + 8ebe466 commit 8ab6b56
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 61 deletions.
3 changes: 3 additions & 0 deletions config/clusters/2i2c/imagebuilding-demo.values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jupyterhub:
name: 2i2c
url: https://2i2c.org
hub:
image:
name: quay.io/2i2c/dynamic-image-building-experiment
tag: "0.0.1-0.dev.git.6478.h0ab34873"
config:
JupyterHub:
authenticator_class: cilogon
Expand Down
4 changes: 2 additions & 2 deletions config/clusters/leap/common.values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ basehub:
url: https://leap-stc.github.io
hub:
image:
name: quay.io/2i2c/experimental-hub
tag: "0.0.1-0.dev.git.6406.hc1091b1c"
name: quay.io/2i2c/unlisted-choice-experiment
tag: "0.0.1-0.dev.git.6478.h0ab34873"
allowNamedServers: true
config:
Authenticator:
Expand Down
41 changes: 29 additions & 12 deletions docs/howto/custom-jupyterhub-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ This allows adding and configuring other packages like the [jupyterhub-configura
More information about this custom image can be found in the [Dockerfile](https://github.com/2i2c-org/infrastructure/blob/HEAD/helm-charts/images/hub/Dockerfile) itself.


## The `hub-experimental` image
## The experimental hub images

In addition to the `hub` image, there is also a `hub-experimental` image, that is defined in the [helm-charts directory of the infrastructure repository](https://github.com/2i2c-org/infrastructure/tree/HEAD/helm-charts/images/hub-experimental).
In addition to the `hub` image, there are also experimental hub images, that are defined alongside the main `hub` image in the [helm-charts directory of the infrastructure repository](https://github.com/2i2c-org/infrastructure/tree/HEAD/helm-charts/images/hub), through individual `requirements.txt` files, named after the experiment that's being performed.

This `hub-experimental` image is very similar to the hub image, but its primary goal is to be used to test changes like new packages, newer package versions, or even unreleased or unmerged versions of them. It can be used to deploy such change just to one or a few specific communities, without having to worry about the instabilities it can generate for other communities.
The experimental hub images and the main `hub` image are quite similar. They are based off the same `Dockerfile`, but use different `requirements.txt` files, because their primary goal is to be used to test changes like new packages, newer package versions, or even unreleased or unmerged versions of them. They are used to deploy such changes just to one or a few specific communities, without having to worry about the instabilities they can generate for other communities.

```{note}
Both the 2i2c custom `hub` and the `hub-experimental` images live at [Quay.io](https://quay.io/organization/2i2c).
```

## When to roll out the changes in `hub-experimental` to `hub`
## When to roll out the changes in the experimental images to `hub`

```{important}
Our current policy states that a change in `hub-experimental` must be rolled out into `hub`, **within 4 weeks**, otherwise it should be removed. Any issues identified within these 4 weeks, must be fixed it until it's good enough to deploy to all hubs.
Our current policy states that a change in a hub experimental image must be rolled out into `hub`, **within 4 weeks**, otherwise it should be removed. Any issues identified within these 4 weeks, must be fixed it until it's good enough to deploy to all hubs.
```

The workflow is the following:
Expand All @@ -39,8 +39,25 @@ flowchart TD
-- More testing for hubs that are configured differently ---
deploy_everywhere --> end_condition[fa:fa-exclamation `hub-experimental` image is the same as `hub`]
```
## How to create a new hub experimental image

## How to install an unreleased version of a package in the `hub-experimental` image
1. You will first need to create a new `.txt` file with a name relevant for the experiment, let's say `new-experiment-requirements.txt`.

2. Then, `chartpress` must be instructed to create a new docker image using the `new-experiment-requirements.txt`
To do this, edit the `chartpress.yaml` file located at the root of the `helm-chartes/images` directory to add another image under the `basehub` chart:

```yaml
new-experiment:
imageName: quay.io/2i2c/new-experiment
buildArgs:
REQUIREMENTS_FILE: "new-experiment-requirements.txt"
contextPath: "images/hub"
dockerfilePath: images/hub/Dockerfile
```
3. Go to https://quay.io/new/ and create a new _public_ repository using your `2i2c` organizational account. Name it the same with the suffix of the name set under `imageName` from `chartpress.yaml`. In this example is `new-experiment`.

## How to install an unreleased version of a package in an experimental hub image

To install an unreleased package, we will need to install directly from GitHub and not from PyPI:

Expand All @@ -54,7 +71,7 @@ To install an unreleased package, we will need to install directly from GitHub a
https://github.com/jupyterhub/kubespawner@def501f1d60b8e5629745acb0bcc45b151b1decc
```

2. Update the [requirements.txt](https://github.com/2i2c-org/infrastructure/blob/HEAD/helm-charts/images/hub-experimental/requirements.txt) file to add this package and commit, prefixed by a `git+` on a new row
2. Update the `.txt` file of this specific experiment, let's say `new-experiment-requirements.txt`, to add this package and commit, prefixed by a `git+` on a new row

```bash
git+https://github.com/jupyterhub/kubespawner@def501f1d60b8e5629745acb0bcc45b151b1decc
Expand All @@ -63,15 +80,15 @@ To install an unreleased package, we will need to install directly from GitHub a
3. Commit the changes

```bash
git add helm-charts/images/hub/Dockerfile
git add helm-charts/images/hub/new-experiment-requirements.txt
git commit
```

```{note}
The commit SHA with be used to generate the image tag.
```

## How to build and push a new version of the hub image (`hub` or `hub-experimental`)
## How to build and push a new version of the available hub images

Rebuild the Docker image and push it to the [Quay.io registry](https://quay.io/repository/2i2c/pilot-hub)

Expand Down Expand Up @@ -121,16 +138,16 @@ Rebuild the Docker image and push it to the [Quay.io registry](https://quay.io/r
git commit
```

- **If building and pushing the `hub-experimental` image**, then discard the changes to both `helm-charts/basehub/values.yaml` and `helm-charts/basehub/Chart.yaml`, because we only want to deploy this image to particular hubs
- **If building and pushing any of the experimental images**, then discard the changes to both `helm-charts/basehub/values.yaml` and `helm-charts/basehub/Chart.yaml`, because we only want to deploy this image to particular hubs

## How to configure a hub to use the new `hub-experimental` image
## How to configure a hub to use an experimental new image

You will need to put a config similar to the one below in your hub configuration file:

```
hub:
image:
name: quay.io/2i2c/experimental-hub
name: quay.io/2i2c/new-experiment
tag: "0.0.1-0.dev.git.6406.hc1091b1c"
```

Expand Down
2 changes: 1 addition & 1 deletion helm-charts/basehub/templates/user-sa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ kind: ServiceAccount
metadata:
annotations: {{ .Values.userServiceAccount.annotations | toJson}}
name: user-sa
{{- end }}
{{- end }}
18 changes: 14 additions & 4 deletions helm-charts/chartpress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ charts:
images:
hub:
valuesPath: jupyterhub.hub.image
- name: basehub
images:
hub-experimental:
imageName: quay.io/2i2c/experimental-hub
buildArgs:
REQUIREMENTS_FILE: "requirements.txt"
unlisted-choice-experiment:
imageName: quay.io/2i2c/unlisted-choice-experiment
buildArgs:
REQUIREMENTS_FILE: "unlisted-choice-requirements.txt"
contextPath: "images/hub"
dockerfilePath: images/hub/Dockerfile
dynamic-image-building-experiment:
imageName: quay.io/2i2c/dynamic-image-building-experiment
buildArgs:
REQUIREMENTS_FILE: "dynamic-image-building-requirements.txt"
contextPath: "images/hub"
dockerfilePath: "images/hub/Dockerfile"
25 changes: 0 additions & 25 deletions helm-charts/images/hub-experimental/Dockerfile

This file was deleted.

This file was deleted.

5 changes: 3 additions & 2 deletions helm-charts/images/hub/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
# 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
ARG REQUIREMENTS_FILE

COPY requirements.txt /tmp/
COPY ${REQUIREMENTS_FILE} /tmp/

RUN pip install -r /tmp/requirements.txt
RUN pip install -r /tmp/${REQUIREMENTS_FILE}

USER root
RUN mkdir -p /usr/local/etc/jupyterhub-configurator
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Image lives at quay.io/2i2c/second-hub-experimental
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
# Brings in https://github.com/yuvipanda/prototype-kubespawner-dynamic-building-ui
git+https://github.com/yuvipanda/prototype-kubespawner-dynamic-building-ui@ce6fd9a67edc7cbe62dd8701954f8dd0bb94b312

0 comments on commit 8ab6b56

Please sign in to comment.