Creating catalogs
Catalog maintainers can create new catalogs in the file-based catalog format for use with Operator Lifecycle Manager (OLM) v1 on OpenShift Container Platform.
Creating a file-based catalog image
You can use the opm CLI to create a catalog image that uses the plain text file-based catalog format (JSON or YAML), which replaces the deprecated SQLite database format.
-
You have installed the
opmCLI. -
You have
podmanversion 1.9.3+. -
A bundle image is built and pushed to a registry that supports Docker v2-2.
-
Initialize the catalog:
-
Create a directory for the catalog by running the following command:
$ mkdir <catalog_dir> -
Generate a Dockerfile that can build a catalog image by running the
opm generate dockerfilecommand:$ opm generate dockerfile <catalog_dir> \ -i registry.redhat.io/openshift4/ose-operator-registry-rhel9:v4.19- Specify the official Red Hat base image by using the
-iflag, otherwise the Dockerfile uses the default upstream image.
The Dockerfile must be in the same parent directory as the catalog directory that you created in the previous step:
Example directory structure. ├── <catalog_dir> └── <catalog_dir>.Dockerfile- Parent directory
- Catalog directory
- Dockerfile generated by the
opm generate dockerfilecommand
- Specify the official Red Hat base image by using the
-
Populate the catalog with the package definition for your Operator by running the
opm initcommand:$ opm init <operator_name> \ --default-channel=preview \ --description=./README.md \ --icon=./operator-icon.svg \ --output yaml \ > <catalog_dir>/index.yaml- Operator, or package, name
- Channel that subscriptions default to if unspecified
- Path to the Operator’s
README.mdor other documentation - Path to the Operator’s icon
- Output format: JSON or YAML
- Path for creating the catalog configuration file
This command generates an
olm.packagedeclarative config blob in the specified catalog configuration file.
-
-
Add a bundle to the catalog by running the
opm rendercommand:$ opm render <registry>/<namespace>/<bundle_image_name>:<tag> \ --output=yaml \ >> <catalog_dir>/index.yaml- Pull spec for the bundle image
- Path to the catalog configuration file
Note
Channels must contain at least one bundle.
-
Add a channel entry for the bundle. For example, modify the following example to your specifications, and add it to your
<catalog_dir>/index.yamlfile:Example channel entry--- schema: olm.channel package: <operator_name> name: preview entries: - name: <operator_name>.v0.1.0- Ensure that you include the period (
.) after<operator_name>but before thevin the version. Otherwise, the entry fails to pass theopm validatecommand.
- Ensure that you include the period (
-
Validate the file-based catalog:
-
Run the
opm validatecommand against the catalog directory:$ opm validate <catalog_dir> -
Check that the error code is
0:$ echo $?Example output0
-
-
Build the catalog image by running the
podman buildcommand:$ podman build . \ -f <catalog_dir>.Dockerfile \ -t <registry>/<namespace>/<catalog_image_name>:<tag> -
Push the catalog image to a registry:
-
If required, authenticate with your target registry by running the
podman logincommand:$ podman login <registry> -
Push the catalog image by running the
podman pushcommand:$ podman push <registry>/<namespace>/<catalog_image_name>:<tag>
-
Updating or filtering a file-based catalog image
You can use the opm CLI to update or filter a catalog image that uses the file-based catalog format. By extracting the contents of an existing catalog image, you can modify the catalog as needed, for example:
-
Adding packages
-
Removing packages
-
Updating existing package entries
-
Detailing deprecation messages per package, channel, and bundle
You can then rebuild the image as an updated version of the catalog.
Note
Alternatively, if you already have a catalog image on a mirror registry, you can use the oc-mirror CLI plugin to automatically prune any removed images from an updated source version of that catalog image while mirroring it to the target registry.
For more information about the oc-mirror plugin and this use case, see the "Keeping your mirror registry content updated" section, and specifically the "Pruning images" subsection, of "Mirroring images for a disconnected installation using the oc-mirror plugin".
-
You have the following on your workstation:
-
The
opmCLI. -
podmanversion 1.9.3+. -
A file-based catalog image.
-
A catalog directory structure recently initialized on your workstation related to this catalog.
If you do not have an initialized catalog directory, create the directory and generate the Dockerfile. For more information, see the "Initialize the catalog" step from the "Creating a file-based catalog image" procedure.
-
-
Extract the contents of the catalog image in YAML format to an
index.yamlfile in your catalog directory:$ opm render <registry>/<namespace>/<catalog_image_name>:<tag> \ -o yaml > <catalog_dir>/index.yamlNote
Alternatively, you can use the
-o jsonflag to output in JSON format. -
Modify the contents of the resulting
index.yamlfile to your specifications:Important
After a bundle has been published in a catalog, assume that one of your users has installed it. Ensure that all previously published bundles in a catalog have an update path to the current or newer channel head to avoid stranding users that have that version installed.
-
To add an Operator, follow the steps for creating package, bundle, and channel entries in the "Creating a file-based catalog image" procedure.
-
To remove an Operator, delete the set of
olm.package,olm.channel, andolm.bundleblobs that relate to the package. The following example shows a set that must be deleted to remove theexample-operatorpackage from the catalog:Example removed entries
--- defaultChannel: release-2.7 icon: base64data: <base64_string> mediatype: image/svg+xml name: example-operator schema: olm.package --- entries: - name: example-operator.v2.7.0 skipRange: '>=2.6.0 <2.7.0' - name: example-operator.v2.7.1 replaces: example-operator.v2.7.0 skipRange: '>=2.6.0 <2.7.1' - name: example-operator.v2.7.2 replaces: example-operator.v2.7.1 skipRange: '>=2.6.0 <2.7.2' - name: example-operator.v2.7.3 replaces: example-operator.v2.7.2 skipRange: '>=2.6.0 <2.7.3' - name: example-operator.v2.7.4 replaces: example-operator.v2.7.3 skipRange: '>=2.6.0 <2.7.4' name: release-2.7 package: example-operator schema: olm.channel --- image: example.com/example-inc/example-operator-bundle@sha256:<digest> name: example-operator.v2.7.0 package: example-operator properties: - type: olm.gvk value: group: example-group.example.io kind: MyObject version: v1alpha1 - type: olm.gvk value: group: example-group.example.io kind: MyOtherObject version: v1beta1 - type: olm.package value: packageName: example-operator version: 2.7.0 - type: olm.bundle.object value: data: <base64_string> - type: olm.bundle.object value: data: <base64_string> relatedImages: - image: example.com/example-inc/example-related-image@sha256:<digest> name: example-related-image schema: olm.bundle --- -
To add or update deprecation messages for an Operator, ensure there is a
deprecations.yamlfile in the same directory as the package’sindex.yamlfile. For information on thedeprecations.yamlfile format, see "olm.deprecations schema".
-
-
Save your changes.
-
Validate the catalog:
$ opm validate <catalog_dir> -
Rebuild the catalog:
$ podman build . \ -f <catalog_dir>.Dockerfile \ -t <registry>/<namespace>/<catalog_image_name>:<tag> -
Push the updated catalog image to a registry:
$ podman push <registry>/<namespace>/<catalog_image_name>:<tag>
-
In the web console, navigate to the OperatorHub configuration resource in the Administration → Cluster Settings → Configuration page.
-
Add the catalog source or update the existing catalog source to use the pull spec for your updated catalog image.
For more information, see "Adding a catalog source to a cluster" in the "Additional resources" of this section.
-
After the catalog source is in a READY state, navigate to the Ecosystem → Software Catalog page. Select Operators under the Type heading and check that the changes you made are reflected in the list of Operators.