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 {productname-short} dashboard so that your data scientist users can select it when they create a workbench.
-
You have cluster administrator privileges for your {openshift-platform} cluster.
-
You have installed the OpenShift command-line interface (CLI). See Installing the OpenShift CLI.
-
In a terminal window, if you are not already logged in to your {openshift-platform} cluster as a cluster administrator, log in as shown in the following example:
oc login <openshift_cluster_url> -u <admin_username> -p <password>
-
Define the
ImageStream
CRD.-
Create a YAML manifest file named
notebook-image-stream.yaml
. -
Copy the following configuration and paste it in the
notebook-image-stream.yaml
file:ExampleImageStream
kind: ImageStream apiVersion: image.openshift.io/v1 metadata: annotations: opendatahub.io/notebook-image-desc: A custom Jupyter Notebook image # (1) opendatahub.io/notebook-image-name: My Custom Notebook # (2) name: my-custom-notebook namespace: redhat-ods-applications # (3) labels: # (4) app.kubernetes.io/created-by: byon opendatahub.io/dashboard: 'true' opendatahub.io/notebook-image: 'true' opendatahub.io/component: 'true' platform.opendatahub.io/part-of: 'workbenches' app.kubernetes.io/part-of: 'workbenches' spec: lookupPolicy: local: true tags: - name: '1.0' # (5) annotations: # (6) opendatahub.io/notebook-python-dependencies: '[{"name":"PyTorch","version":"2.2"}]' # (7) opendatahub.io/notebook-software: '[{"name":"Python","version":"v3.11"}]' # (8) opendatahub.io/workbench-image-recommended: 'true' # (9) from: kind: DockerImage name: 'image-registry.openshift-image-registry.svc:5000/redhat-ods-applications/my-custom-workbench:latest' # (10) importPolicy: importPolicy: importMode: Legacy referencePolicy: type: Source
The example YAML file includes the following information:
-
A description of the image.
-
The image name that is displayed in the drop down menu when a user creates a workbench in the {productname-short} dashboard.
-
The
redhat-ods-applications
namespace is the default namespace in which theImageStream
CR is created. -
The labels that are required if you want the image to appear in the {productname-short} dashboard. The
app.kubernetes.io/created-by: byon
label identifies the origination of the image object. -
Annotations that are required if you want to make the image available in the {productname-short} dashboard.
-
The version for the image. You can configure multiple versions for the same image. For this example, the version is 1.0.
-
An annotation that gives the user information about the Python packages and versions that are pre-installed in the image.
-
An annotation that specifies information such as the Python version, Jupyter version, or CUDA version.
-
An annotation that specifies whether the
ImageStream
version is the default version of the image. Set this field to'true'
if theImageStream
version is the default. Otherwise, set it to'false'
. You must specify theopendatahub.io/workbench-image-recommended
annotation 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'
. -
The image registry URL to store the image stream. Store the image stream in an image registry outside of the cluster where {productname-short} is installed.
-
-
-
To create the
ImageStream
CR, run the following command, where theImageStream
CRD YAML manifest file name isnotebook-image-stream.yaml
:oc create -f notebook-image-stream.yaml
-
To verify that the
ImageStream
was successfully created, run the following command, where the name of theImageStream
ismy-custom-notebook
:oc describe imagestream my-custom-notebook -n redhat-ods-applications
You should see output similar to the following example:
Example outputName: my-custom-notebook Namespace: redhat-ods-applications Created: 6 minutes ago Labels: app.kubernetes.io/created-by=byon opendatahub.io/dashboard=true opendatahub.io/notebook-image=true Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"image.openshift.io/v1","kind":"ImageStream","metadata":{"annotations":{"opendatahub.io/notebook-image-desc":"A custom Jupyter Notebook image","opendatahub.io/notebook-image-name":"My Custom Notebook"},"labels":{"app.kubernetes.io/created-by":"byon","opendatahub.io/dashboard":"true","opendatahub.io/notebook-image":"true"},"name":"my-custom-notebook","namespace":"redhat-ods-applications"},"spec":{"lookupPolicy":{"local":true},"tags":[{"annotations":{"opendatahub.io/notebook-python-dependencies":"[{\"name\":\"PyTorch\",\"version\":\"2.2\"}]","opendatahub.io/notebook-software":"[{\"name\":\"Python\",\"version\":\"v3.11\"}]","opendatahub.io/workbench-image-recommended":"true"},"from":{"kind":"DockerImage","name":"quay.io/modh/rocm-notebooks@sha256:199367d2946fc8....8279b10150020af22db"},"importPolicy":{"importMode":"Legacy"},"name":"1.0","referencePolicy":{"type":"Source"}}]}} opendatahub.io/notebook-image-desc=A custom Jupyter Notebook image opendatahub.io/notebook-image-name=My Custom Notebook openshift.io/image.dockerRepositoryCheck=2025-03-10T11:02:44Z Image Repository: image-registry.openshift-image-registry.svc:5000/redhat-ods-applications/my-custom-notebook Image Lookup: local=true Unique Images: 1 Tags: 1 1.0 tagged from quay.io/modh/rocm-notebooks@sha256:199367d2946..b411433ffbb5f0988279b10150020af22db * quay.io/modh/rocm-notebooks@sha256:199367d2946fc8427....1433ffbb5f0988279b10150020af22db 6 minutes ago
-
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 Repository
and theTags
fields from theImageStream
output.In the following example, the
Image Repository
value isimage-registry.openshift-image-registry.svc:5000/redhat-ods-applications/my-custom-notebook
and theTags
value is1.0
:Example output.... Image Repository: image-registry.openshift-image-registry.svc:5000/redhat-ods-applications/my-custom-notebook Image Lookup: local=true Unique Images: 1 Tags: 1 1.0 tagged from quay.io/modh/rocm-notebooks@sha256:199367d2946..b411433ffbb5f0988279b10150020af22db ....
-
Create a fully-formed image URL by combining the values for the
Image Repository
and theTags
fields, as shown in the following example:image-registry.openshift-image-registry.svc:5000/redhat-ods-applications/my-custom-notebook:1.0
-