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.
Prerequisites
- 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.
Procedure
-
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.22Specify 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>.Dockerfilewhere:
.- Specifies the parent directory.
<catalog_dir>- Specifies the catalog directory.
<catalog_dir>.Dockerfile- Specifies the Dockerfile generated by the
opm generate dockerfilecommand.
-
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- Replace the
<operator_name>variable with the Operator or package, name. - The
--default-channelflag specifies the channel that subscriptions default to if unspecified. - The
--descriptionflag specifies the path to the Operator’sREADME.mdor other documentation. - The
--iconflag specifies the path to the Operator’s icon. - The
--outputflag specifies the output format.JSONorYAMLare valid values. - Replace the
<catalog_dir>variable with the path for creating the catalog configuration file. This command generates anolm.packagedeclarative config blob in the specified catalog configuration file.
- Replace the
-
-
Add a bundle to the catalog by running the
opm rendercommand:$ opm render <registry>/<namespace>/<bundle_image_name>:<tag> \--output=yaml \>> <catalog_dir>/index.yamlwhere:
- <registry>/<namespace>/<bundle_image_name>:<tag>
- Specifies the pull spec for the bundle image.
- <catalog_dir>/index.yaml
- Specifies the path to the catalog configuration file.
noteChannels 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.channelpackage: <operator_name>name: previewentries:- name: <operator_name>.v0.1.0Ensure that you include the period (
.) after the<operator_name>variable but before thevin the version. Otherwise, the entry fails to pass theopm validatecommand. -
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>
- If required, authenticate with your target registry by running the
Additional resources
Updating or filtering a file-based catalog image
To keep your catalog accurate and ensure users can safely upgrade installed Operators, you can use the opm CLI to extract, edit, and rebuild a file-based catalog image. You can also specify deprecation messages for packages, channels, and bundles.
After you complete the changes, you can rebuild the image as an updated version of the catalog.
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".
Prerequisites
- 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.
- The
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.yamlnoteAlternatively, you can use the
-o jsonflag to output in JSON format. -
Modify the contents of the resulting
index.yamlfile to your specifications:warningAfter 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.7icon:base64data: <base64_string>mediatype: image/svg+xmlname: example-operatorschema: olm.package---entries:- name: example-operator.v2.7.0skipRange: '>=2.6.0 <2.7.0'- name: example-operator.v2.7.1replaces: example-operator.v2.7.0skipRange: '>=2.6.0 <2.7.1'- name: example-operator.v2.7.2replaces: example-operator.v2.7.1skipRange: '>=2.6.0 <2.7.2'- name: example-operator.v2.7.3replaces: example-operator.v2.7.2skipRange: '>=2.6.0 <2.7.3'- name: example-operator.v2.7.4replaces: example-operator.v2.7.3skipRange: '>=2.6.0 <2.7.4'name: release-2.7package: example-operatorschema: olm.channel---image: example.com/example-inc/example-operator-bundle@sha256:<digest>name: example-operator.v2.7.0package: example-operatorproperties:- type: olm.gvkvalue:group: example-group.example.iokind: MyObjectversion: v1alpha1- type: olm.gvkvalue:group: example-group.example.iokind: MyOtherObjectversion: v1beta1- type: olm.packagevalue:packageName: example-operatorversion: 2.7.0- type: olm.bundle.objectvalue:data: <base64_string>- type: olm.bundle.objectvalue:data: <base64_string>relatedImages:- image: example.com/example-inc/example-related-image@sha256:<digest>name: example-related-imageschema: 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>
Verification
- 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".
- 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.
Additional resources