4.5. 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.
4.5.1. 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.211 - 1
- 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
.1 ├── <catalog_dir>2 └── <catalog_dir>.Dockerfile3 Populate the catalog with the package definition for your Operator by running the
opm initcommand:$ opm init <operator_name> \1 --default-channel=preview \2 --description=./README.md \3 --icon=./operator-icon.svg \4 --output yaml \5 > <catalog_dir>/index.yaml6 - 1
- Operator, or package, name
- 2
- Channel that subscriptions default to if unspecified
- 3
- Path to the Operator’s
README.mdor other documentation - 4
- Path to the Operator’s icon
- 5
- Output format: JSON or YAML
- 6
- 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> \1 --output=yaml \ >> <catalog_dir>/index.yaml2 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.01 - 1
- Ensure that you include the period (
.) after<operator_name>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 output
0
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>