|
| 1 | +# Examples |
| 2 | + |
| 3 | +## JupyterLab with Elyra |
| 4 | + |
| 5 | +This Workbench image installs JupyterLab and the ODH-Elyra extension. |
| 6 | + |
| 7 | +The main difference between the [upstream Elyra](https://github.com/elyra-ai/elyra) and the [ODH-Elyra fork](https://github.com/opendatahub-io/elyra) is that the fork implements Argo Pipelines support, which is required for executing pipelines in OpenDataHub/OpenShift AI. |
| 8 | +Specifically, the fork already includes the changes from [elyra-ai/elyra #3273](https://github.com/elyra-ai/elyra/pull/3273), which is still pending upstream. |
| 9 | + |
| 10 | +### Design |
| 11 | + |
| 12 | +The workbench is based on a Source-to-Image (S2I) UBI9 Python 3.11 image. |
| 13 | +This means—besides having Python 3.11 installed—that it also has the following |
| 14 | +* Python virtual environment at `/opt/app-root` is activated by default |
| 15 | +* `HOME` directory is set to `/opt/app-root/src` |
| 16 | +* port 8888 is `EXPOSE`D by default |
| 17 | + |
| 18 | +These characteristics are required for OpenDataHub workbenches to function. |
| 19 | + |
| 20 | +#### Integration with OpenDataHub Notebook Controller and Notebook Dashboard |
| 21 | + |
| 22 | +#### OpenDataHub Dashboard |
| 23 | + |
| 24 | +Dashboard automatically populates an environment variable named `NOTEBOOK_ARGS` when starting a container from this image. |
| 25 | +This variable contains configurations that are necessary to integrate with Dashboard regarding launching the Workbench and logging off. |
| 26 | + |
| 27 | +Reference: https://github.com/opendatahub-io/odh-dashboard/blob/95d80a0cccd5053dc0ca372effcdcd8183a0d5b8/frontend/src/api/k8s/notebooks.ts#L143-L149 |
| 28 | + |
| 29 | +Furthermore, when configuring a workbench, the default Persistent Volume Claim (PVC) is created and volume is mounted at `/opt/app-root/src` in the workbench container. |
| 30 | +This means that changing the user's `HOME` directory from the expected default is inadvisable. |
| 31 | +It further means that whatever the original content of `/opt/app-root/src` in the image may be, it will be shadowed by the PVC. |
| 32 | + |
| 33 | +##### OpenDataHub Notebook Controller |
| 34 | + |
| 35 | +During the Notebook Custom Resource (CR) creation, the mutating webhook in Notebook Controller is triggered. |
| 36 | +This webhook is responsible for configuring OAuth Proxy, certificate bundles, pipeline runtime, runtime images, and maybe more. |
| 37 | +It also creates a service and OpenShift route to make the Workbench reachable from the outside of the cluster. |
| 38 | + |
| 39 | +**OAuth Proxy** is configured to connect to port 8888 of the workbench container (discussed above) and listen for incoming connections on port 8443. |
| 40 | + |
| 41 | +Reference: https://github.com/opendatahub-io/kubeflow/blob/eacf63cdaed4db766a6503aa413e388e1d2721ef/components/odh-notebook-controller/controllers/notebook_webhook.go#L114-L121 |
| 42 | + |
| 43 | +**Certificate bundles** are added as a file-mounted configmap at `/etc/pki/tls/custom-certs/ca-bundle.crt`. |
| 44 | +This is a nonstandard location, so it is necessary to also add environment variables that instruct various software to reference this bundle during operation. |
| 45 | + |
| 46 | +Reference: |
| 47 | +* https://github.com/opendatahub-io/kubeflow/blob/eacf63cdaed4db766a6503aa413e388e1d2721ef/components/odh-notebook-controller/controllers/notebook_webhook.go#L598 |
| 48 | +* https://github.com/opendatahub-io/kubeflow/blob/eacf63cdaed4db766a6503aa413e388e1d2721ef/components/odh-notebook-controller/controllers/notebook_webhook.go#L601-L607 |
| 49 | + |
| 50 | +**Pipeline runtime configuration** is obtained from a Data Science Pipeline Application (DSPA) CR. |
| 51 | +The DSPA CR is first located in the same project where the workbench is being started, a secret with the connection data is created, and then this secret is mounted. |
| 52 | +The secret is mounted under `/opt/app-root/runtimes/`. |
| 53 | + |
| 54 | +Reference: https://github.com/opendatahub-io/kubeflow/blob/eacf63cdaed4db766a6503aa413e388e1d2721ef/components/odh-notebook-controller/controllers/notebook_dspa_secret.go#L42C28-L42C50 |
| 55 | + |
| 56 | +IMPORTANT: the `setup-elyra.sh` script in this repo relies on this location. |
| 57 | + |
| 58 | +**Runtime images** are processed very similarly to the DSPA configuration. |
| 59 | +First, image stream resources are examined, and then a configmap is created and mounted to every newly started workbench. |
| 60 | +The mount location is under `/opt/app-root/pipeline-runtimes/`. |
| 61 | + |
| 62 | +Reference: https://github.com/opendatahub-io/kubeflow/blob/eacf63cdaed4db766a6503aa413e388e1d2721ef/components/odh-notebook-controller/controllers/notebook_runtime.go#L25C19-L25C51 |
| 63 | + |
| 64 | +IMPORTANT: the `setup-elyra.sh` script in this repo again relies on this location. |
| 65 | + |
| 66 | +### Build |
| 67 | + |
| 68 | +```shell |
| 69 | +podman build -f examples/jupyterlab-with-elyra/Dockerfile -t quay.io/your-username/jupyterlab-with-elyra:latest . |
| 70 | +podman push quay.io/your-username/jupyterlab-with-elyra:latest |
| 71 | +``` |
| 72 | + |
| 73 | +### Deploy |
| 74 | + |
| 75 | +Open the `Settings > Workbench images` page in OpenDataHub Dashboard. |
| 76 | +Click on the `Import new image` button and add the image you have just pushed. |
| 77 | +The `Image location` field should be set to `quay.io/your-username/jupyterlab-with-elyra:latest`, or wherever the image is pushed and available for the cluster to pull. |
| 78 | +Values of other fields do not matter for functionality, but they let you keep better track of previously imported images. |
| 79 | + |
| 80 | +There is a special ODH Dashboard feature that alerts you when you are using a workbench image that lists the `elyra` instead of `odh-elyra` package. |
| 81 | +This code will have to be updated when `elyra` also gains support for Argo Pipelines, but for now it does the job. |
| 82 | + |
| 83 | +Reference: https://github.com/opendatahub-io/odh-dashboard/blob/2ced77737a1b1fc24b94acac41245da8b29468a4/frontend/src/concepts/pipelines/elyra/utils.ts#L152-L162 |
0 commit comments