Create 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:v{product-version}+ 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>.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 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.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.
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.0Ensure that you include the period (
.) after the<operator_name>`variable but before the `vin 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>
-