Chapter 3. Creating a workbench by using the Notebook CRD
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