|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * operators/admin/olm-managing-custom-catalogs.adoc |
| 4 | + |
| 5 | +ifdef::openshift-origin[] |
| 6 | +:registry-image: quay.io/openshift/origin-operator-registry:4.9.0 |
| 7 | +endif::[] |
| 8 | +ifndef::openshift-origin[] |
| 9 | +:registry-image: registry.redhat.io/openshift4/ose-operator-registry:v4.9 |
| 10 | +endif::[] |
| 11 | + |
| 12 | +[id="olm-creating-fb-catalog-image_{context}"] |
| 13 | += Creating a file-based catalog image |
| 14 | + |
| 15 | +You can create a catalog image that uses the plain text _file-based catalog_ format (JSON or YAML), which replaces the deprecated SQLite database format. The `opm` CLI provides tooling that helps initialize a catalog in the file-based format, render new records into it, and validate that the catalog is valid. |
| 16 | + |
| 17 | +.Prerequisites |
| 18 | + |
| 19 | +* `opm` version 1.18.0+ |
| 20 | +* `podman` version 1.9.3+ |
| 21 | +* A bundle image built and pushed to a registry that supports link:https://docs.docker.com/registry/spec/manifest-v2-2/[Docker v2-2] |
| 22 | + |
| 23 | +.Procedure |
| 24 | + |
| 25 | +. Initialize a catalog for a file-based catalog: |
| 26 | + |
| 27 | +.. Create a directory for the catalog: |
| 28 | ++ |
| 29 | +[source,terminal] |
| 30 | +---- |
| 31 | +$ mkdir <operator_name>-index |
| 32 | +---- |
| 33 | + |
| 34 | +.. Create a Dockerfile that can build a catalog image: |
| 35 | ++ |
| 36 | +.Example `<operator_name>-index.Dockerfile` |
| 37 | +[source,bash,subs="attributes+"] |
| 38 | +---- |
| 39 | +# The base image is expected to contain |
| 40 | +# /bin/opm (with a serve subcommand) and /bin/grpc_health_probe |
| 41 | +FROM {registry-image} |
| 42 | +
|
| 43 | +# Configure the entrypoint and command |
| 44 | +ENTRYPOINT ["/bin/opm"] |
| 45 | +CMD ["serve", "/configs"] |
| 46 | +
|
| 47 | +# Copy declarative config root into image at /configs |
| 48 | +ADD <operator_name>-index /configs |
| 49 | +
|
| 50 | +# Set DC-specific label for the location of the DC root directory |
| 51 | +# in the image |
| 52 | +LABEL operators.operatorframework.io.index.configs.v1=/configs |
| 53 | +---- |
| 54 | ++ |
| 55 | +The Dockerfile must be in the same parent directory as the catalog directory that you created in the previous step: |
| 56 | ++ |
| 57 | +.Example directory structure |
| 58 | +[source,terminal] |
| 59 | +---- |
| 60 | +. |
| 61 | +├── <operator_name>-index |
| 62 | +└── <operator_name>-index.Dockerfile |
| 63 | +---- |
| 64 | + |
| 65 | +.. Populate the catalog with your package definition: |
| 66 | ++ |
| 67 | +[source,terminal] |
| 68 | +---- |
| 69 | +$ opm init <operator_name> \ <.> |
| 70 | + --default-channel=preview \ <.> |
| 71 | + --description=./README.md \ <.> |
| 72 | + --icon=./operator-icon.svg \ <.> |
| 73 | + --output yaml \ <.> |
| 74 | + > <operator_name>-index/index.yaml <.> |
| 75 | +---- |
| 76 | +<.> Operator, or package, name. |
| 77 | +<.> Channel that subscription will default to if unspecified. |
| 78 | +<.> Path to the Operator's `README.md` or other documentation. |
| 79 | +<.> Path to the Operator's icon. |
| 80 | +<.> Output format: JSON or YAML. |
| 81 | +<.> Path for creating the catalog configuration file. |
| 82 | ++ |
| 83 | +This command generates an `olm.package` declarative config blob in the specified catalog configuration file. |
| 84 | + |
| 85 | +. Add a bundle to the catalog: |
| 86 | ++ |
| 87 | +[source,terminal] |
| 88 | +---- |
| 89 | +$ opm render <registry>/<namespace>/<bundle_image_name>:<tag> \ <.> |
| 90 | + --output=yaml \ |
| 91 | + >> <operator_name>-index/index.yaml <.> |
| 92 | +---- |
| 93 | +<.> Pull spec for the bundle image. |
| 94 | +<.> Path to the catalog configuration file. |
| 95 | ++ |
| 96 | +The `opm render` command generates a declarative config blob from the provided catalog images and bundle images. |
| 97 | ++ |
| 98 | +[NOTE] |
| 99 | +==== |
| 100 | +Channels must contain at least one bundle. |
| 101 | +==== |
| 102 | + |
| 103 | +. Add a channel entry for the bundle. For example, modify the following example to your specifications, and add it to your `<operator_name>-index/index.yaml` file: |
| 104 | ++ |
| 105 | +.Example channel entry |
| 106 | +[source,yaml] |
| 107 | +---- |
| 108 | +--- |
| 109 | +schema: olm.channel |
| 110 | +package: <operator_name> |
| 111 | +name: preview |
| 112 | +entries: |
| 113 | + - name: <operator_name>.v0.1.0 <.> |
| 114 | +---- |
| 115 | +<.> Ensure that you include the period (`.`) after `<operator_name>` but before the `v` in the version. Otherwise, the entry will fail to pass the `opm validate` command. |
| 116 | + |
| 117 | +. Validate the file-based catalog: |
| 118 | + |
| 119 | +.. Run the `opm validate` command against the catalog directory: |
| 120 | ++ |
| 121 | +[source,terminal] |
| 122 | +---- |
| 123 | +$ opm validate <operator_name>-index |
| 124 | +---- |
| 125 | + |
| 126 | +.. Check that the error code is `0`: |
| 127 | ++ |
| 128 | +[source,terminal] |
| 129 | +---- |
| 130 | +$ echo $? |
| 131 | +---- |
| 132 | ++ |
| 133 | +.Example output |
| 134 | +[source,terminal] |
| 135 | +---- |
| 136 | +0 |
| 137 | +---- |
| 138 | + |
| 139 | +. Build the catalog image: |
| 140 | ++ |
| 141 | +[source,terminal] |
| 142 | +---- |
| 143 | +$ podman build . \ |
| 144 | + -f <operator_name>-index.Dockerfile \ |
| 145 | + -t <registry>/<namespace>/<catalog_image_name>:<tag> |
| 146 | +---- |
| 147 | + |
| 148 | +. Push the catalog image to a registry: |
| 149 | + |
| 150 | +.. If required, authenticate with your target registry: |
| 151 | ++ |
| 152 | +[source,terminal] |
| 153 | +---- |
| 154 | +$ podman login <registry> |
| 155 | +---- |
| 156 | + |
| 157 | +.. Push the catalog image: |
| 158 | ++ |
| 159 | +[source,terminal] |
| 160 | +---- |
| 161 | +$ podman push <registry>/<namespace>/<catalog_image_name>:<tag> |
| 162 | +---- |
| 163 | + |
| 164 | +:!registry-image: |
0 commit comments