Creating a workbench
Create a workbench and a custom image by using Custom Resource Definitions (CRDs) and the command-line.
Abstract
Chapter 1. Overview Copy linkLink copied to clipboard!
In Red Hat OpenShift AI, a workbench is an isolated area where a data scientist can examine and work with ML models. When you create a workbench, you specify a workbench image. OpenShift AI provides a selection of default workbench images that you can choose from. Each image is optimized with the tools and libraries that a data scientist needs for model development. To view a list of the OpenShift AI default workbench images and their preinstalled packages, see Supported Configurations for 3.x.
As a cluster administrator, you can create a custom image, for example, if a data scientist on your team requires a specific version of a library that is different from the version provided in a default image. For information about OpenShift AI custom images, see Creating custom workbench images.
You have the following options for creating workbenches and custom images:
-
As an OpenShift cluster administrator, you can create a custom image and a workbench by using OpenShift AI Custom Resource Definitions (CRDs) and the OpenShift CLI (
oc) as described in this guide. - As an OpenShift cluster administrator, you can use OpenShift APIs to create resources, such as a custom image. You can programmatically call the APIs through HTTP GET methods in your code, a Bash script, or a Python script. For more information about using the OpenShift APIs to create an ImageStream resource, see the ImageStream entry in the OpenShift API Reference.
- As any OpenShift AI user, you can use the OpenShift AI dashboard to create workbenches and select images, as described in Using project workbenches.
Chapter 2. Creating a custom image by using the ImageStream CRD Copy linkLink copied to clipboard!
You can create a custom image by using the ImageStream Custom Resource Definition (CRD).
In the following procedure, you configure an ImageStream CRD and use it to create the ImageStream Custom Resource (CR) that defines the custom image. The ImageStream CR provides a URL for the custom image, which you need when you want to use the custom image to configure a workbench.
Note: The custom image that you create also becomes available in the OpenShift AI dashboard so that your data scientist users can select it when they create a workbench.
Prerequisites
- You have cluster administrator privileges for your OpenShift cluster.
You have installed the OpenShift CLI (
oc) as described in the appropriate documentation for your cluster:- Installing the OpenShift CLI for OpenShift Container Platform
- Installing the OpenShift CLI for Red Hat OpenShift Service on AWS
Procedure
In a terminal window, if you are not already logged in to your OpenShift cluster as a cluster administrator, log in as shown in the following example:
oc login <openshift_cluster_url> -u <admin_username> -p <password>
oc login <openshift_cluster_url> -u <admin_username> -p <password>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the
ImageStreamCRD.-
Create a YAML manifest file named
notebook-image-stream.yaml. Copy the following configuration and paste it in the
notebook-image-stream.yamlfile:Example
ImageStreamCopy to Clipboard Copied! Toggle word wrap Toggle overflow The example YAML file includes the following information:
- 1
- A description of the image.
- 2
- The image name that is displayed in the drop down menu when a user creates a workbench in the OpenShift AI dashboard.
- 3
- The
redhat-ods-applicationsnamespace is the default namespace in which theImageStreamCR is created. - 4
- The labels that are required if you want the image to appear in the OpenShift AI dashboard. The
app.kubernetes.io/created-by: byonlabel identifies the origination of the image object. - 5
- Annotations that are required if you want to make the image available in the OpenShift AI dashboard.
- 6
- The version for the image. You can configure multiple versions for the same image. For this example, the version is 1.0.
- 7
- An annotation that gives the user information about the Python packages and versions that are pre-installed in the image.
- 8
- An annotation that specifies information such as the Python version, Jupyter version, or CUDA version.
- 9
- An annotation that specifies whether the
ImageStreamversion is the default version of the image. Set this field to'true'if theImageStreamversion is the default. Otherwise, set it to'false'. You must specify theopendatahub.io/workbench-image-recommendedannotation field if there are multiple versions of the image with different configurations. If you have only one version of the image, set the field to'true'. - 10
- An annotation that specifies whether the image version has tags that are outdated and out of the regular maintenance cycle.
- 11
- An annotation that references the commit hash’s build commit ID to identify the sources that the specific tag was built from.
- 12
- The image registry path where the image has been uploaded.
-
Create a YAML manifest file named
To create the
ImageStreamCR, run the following command, where theImageStreamCRD YAML manifest file name isnotebook-image-stream.yaml:oc create -f notebook-image-stream.yaml
oc create -f notebook-image-stream.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
To verify that the
ImageStreamwas successfully created, run the following command, where the name of theImageStreamismy-custom-notebook:oc describe imagestream my-custom-notebook -n redhat-ods-applications
oc describe imagestream my-custom-notebook -n redhat-ods-applicationsCopy to Clipboard Copied! Toggle word wrap Toggle overflow You should see output similar to the following example:
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To determine the URL for your custom image so that you can reference it when you create a workbench:
Make a note of the values for the
Image Repositoryand theTagsfields from theImageStreamoutput.In the following example, the
Image Repositoryvalue isimage-registry.openshift-image-registry.svc:5000/redhat-ods-applications/my-custom-notebookand theTagsvalue is1.0:Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a fully-formed image URL by combining the values for the
Image Repositoryand theTagsfields, as shown in the following example:image-registry.openshift-image-registry.svc:5000/redhat-ods-applications/my-custom-notebook:1.0
image-registry.openshift-image-registry.svc:5000/redhat-ods-applications/my-custom-notebook:1.0Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 3. Creating a workbench by using the Notebook CRD Copy linkLink copied to clipboard!
In OpenShift AI, you can create a workbench object by using the Notebook Custom Resource Definition (CRD).
In the following procedure, you configure a Notebook CRD and then use it to create the Notebook Custom Resource (CR) that defines the workbench.
Prerequisites
- You have cluster administrator privileges for your OpenShift cluster.
You have installed the OpenShift CLI (
oc) as described in the appropriate documentation for your cluster:- Installing the OpenShift CLI for OpenShift Container Platform
- Installing the OpenShift CLI for Red Hat OpenShift Service on AWS
-
You have created a project. In the example in this procedure, the project is named
my-project. -
You know the URL for the image that you want to use in the workbench. The example in this procedure uses the custom image that you created in Creating a custom image by using the
ImageStreamCRD.
Procedure
In a terminal window, if you are not already logged in to your OpenShift cluster as a cluster administrator, log in as shown in the following example:
oc login <openshift_cluster_url> -u <admin_username> -p <password>
oc login <openshift_cluster_url> -u <admin_username> -p <password>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the
NotebookCRD.-
Create a YAML manifest file named
notebook.yaml. Copy the following configuration and paste it in the
notebook.yamlfile:Example
NotebookCopy to Clipboard Copied! Toggle word wrap Toggle overflow The example YAML file includes the following information:
- 1
- The
inject-oauthannotation generates other OAUTH-based configurations, such as, theoauth-proxy, automatically. The default value istrue. - 2
- The
Notebookimage name is visible in the OpenShift AI dashboard. In this example, the image name isMy custom notebook. Optionally, you can name the image according to your use case. - 3
- An optional description of the workbench.
- 4
- The workbench name that is displayed in the OpenShift AI dashboard. In this example, the display name is
My Workbench. - 5
- The name for the workbench. In this example, the workbench name is
my-workbench. - 6
- The project for the workbench. In this example, the project name is
my-project. - 7
- To queue your workbench (Notebook) Pods and manage their resources, add the
kueue.x-k8s.io/queue-namelabel to thespec.template.metadata.labelsof theNotebookCR. Set the value to the name of an existingLocalQueuein your project. This is required only if your project is enabled for Kueue. - 8
- The deployment size for the container. You can set
limitsandrequestsvalues for CPU and memory. - 9
- Environment variables for configuring values, for example, for Jupyter Notebook arguments and SSL/TLS certificates.
- 10
- The
Notebookimage. In this example,image-registry.openshift-image-registry.svc:5000/redhat-ods-applications/my-custom-notebook:1.0is theNotebookimage. You can select the image version based on the packages included in the image. - 11
- The
inject-oauthannotation configures theoauth-proxycontainer section of theNotebook.
-
Create a YAML manifest file named
Edit the
notebooks.opendatahub.io/oauth-logout-urlfield, annotated as (1) in the following example. Replacemy-projectwith the name of the project that you created.Example
NotebookCopy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the
--logout-url=field, annotated as (1) in the following example. Replacemy-projectwith the name of the project that you created.Example
NotebookCopy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the
valuefield of theJUPYTER_IMAGEenvironment variable, annotated as (1) in the following example. Replace the image URL with the URL of the custom image that you created.Example
NotebookCopy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the
imagefield, annotated as (1) in the following example. Replace the image URL with the URL of the custom image that you created.Example
NotebookCopy to Clipboard Copied! Toggle word wrap Toggle overflow To create the
NotebookCR, run the following command, where theNotebookCRD YAML manifest filename isnotebook.yaml.oc create -f notebook.yaml
oc create -f notebook.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
To verify that the workbench was successfully created, run the following command, replacing
my-projectwith the name of the project where you created theNotebookCR.oc describe notebook -n my-project
oc describe notebook -n my-projectCopy to Clipboard Copied! Toggle word wrap Toggle overflow You should see output similar to the following example:
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow