Chapter 2. Creating a custom image by using the ImageStream CRD
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