Managing custom catalogs
This guide describes how to work with custom catalogs for Operators packaged using either the Bundle Format or the legacy Package Manifest Format on Operator Lifecycle Manager (OLM) in OKD.
Additional resources
Custom catalogs using the Bundle Format
Prerequisites
- Install the
opm
CLI.
Creating an index image
You can create an index image using the opm
CLI.
Prerequisites
opm
version 1.12.3+podman
version 1.9.3+A bundle image built and pushed to a registry that supports Docker v2-2
Procedure
Start a new index:
$ opm index add \
--bundles <registry>/<namespace>/<bundle_image_name>:<tag> \(1)
--tag <registry>/<namespace>/<index_image_name>:<tag> \(2)
[--binary-image <registry_base_image>] (3)
1 Comma-separated list of bundle images to add to the index. 2 The image tag that you want the index image to have. 3 Optional: An alternative registry base image to use for serving the catalog. Push the index image to a registry.
If required, authenticate with your target registry:
$ podman login <registry>
Push the index image:
$ podman push <registry>/<namespace>/test-catalog:latest
Creating a catalog from an index image
You can create an Operator catalog from an index image and apply it to an OKD cluster for use with Operator Lifecycle Manager (OLM).
Prerequisites
- An index image built and pushed to a registry.
Procedure
Create a
CatalogSource
object that references your index image.Modify the following to your specifications and save it as a
catalogSource.yaml
file:apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: my-operator-catalog
namespace: olm (1)
spec:
sourceType: grpc
image: <registry>:<port>/<namespace>/catalog:latest (2)
displayName: My Operator Catalog
publisher: <publisher_name> (3)
updateStrategy:
registryPoll: (4)
interval: 30m
1 If you want the catalog source to be available globally to users in all namespaces, specify the olm
namespace. Otherwise, you can specify a different namespace for the catalog to be scoped and available only for that namespace.2 Specify your index image. 3 Specify your name or an organization name publishing the catalog. 4 Catalog sources can automatically check for new versions to keep up to date. Use the file to create the
CatalogSource
object:$ oc apply -f catalogSource.yaml
Verify the following resources are created successfully.
Check the pods:
$ oc get pods -n olm
Example output
NAME READY STATUS RESTARTS AGE
my-operator-catalog-6njx6 1/1 Running 0 28s
marketplace-operator-d9f549946-96sgr 1/1 Running 0 26h
Check the catalog source:
$ oc get catalogsource -n olm
Example output
NAME DISPLAY TYPE PUBLISHER AGE
my-operator-catalog My Operator Catalog grpc 5s
Check the package manifest:
$ oc get packagemanifest -n olm
Example output
NAME CATALOG AGE
jaeger-product My Operator Catalog 93s
You can now install the Operators from the OperatorHub page on your OKD web console.
Updating an index image
After configuring OperatorHub to use a catalog source that references a custom index image, cluster administrators can keep the available Operators on their cluster up to date by adding bundle images to the index image.
You can update an existing index image using the opm index add
command.
Prerequisites
opm
version 1.12.3+podman
version 1.9.3+An index image built and pushed to a registry.
An existing catalog source referencing the index image.
Procedure
Update the existing index by adding bundle images:
$ opm index add \
--bundles <registry>/<namespace>/<new_bundle_image>:<tag> \(1)
--from-index <registry>/<namespace>/<existing_index_image>:<tag> \(2)
--tag <registry>/<namespace>/<existing_index_image>:<tag> (3)
1 A comma-separated list of additional bundle images to add to the index. 2 The existing index that was previously pushed. 3 The image tag that you want the updated index image to have. Push the updated index image:
$ podman push <registry>/<namespace>/<existing_index_image>:<tag>
After Operator Lifecycle Manager (OLM) automatically polls the index image referenced in the catalog source at its regular interval, verify that the new packages are successfully added:
$ oc get packagemanifests -n openshift-marketplace
Pruning an index image
An index image, based on the Operator Bundle Format, is a containerized snapshot of an Operator catalog. You can prune an index of all but a specified list of packages, which creates a copy of the source index containing only the Operators that you want.
Prerequisites
podman
version 1.9.3+opm
version 1.12.3+Access to a registry that supports Docker v2-2
Procedure
Authenticate with your target registry:
$ podman login <target_registry>
Determine the list of packages you want to include in your pruned index.
Run the source index image that you want to prune in a container. For example:
$ podman run -p50051:50051 \
-it quay.io/operatorhubio/catalog:latest
Example output
Trying to pull quay.io/operatorhubio/catalog:latest...
Getting image source signatures
Copying blob ae8a0c23f5b1 done
...
INFO[0000] serving registry database=/database/index.db port=50051
In a separate terminal session, use the
grpcurl
command to get a list of the packages provided by the index:$ grpcurl -plaintext localhost:50051 api.Registry/ListPackages > packages.out
Inspect the
packages.out
file and identify which package names from this list you want to keep in your pruned index. For example:Example snippets of packages list
...
{
"name": "couchdb-operator"
}
...
{
"name": "eclipse-che"
}
...
{
{
"name": "etcd"
}
...
In the terminal session where you executed the
podman run
command, press Ctrl and C to stop the container process.
Run the following command to prune the source index of all but the specified packages:
$ opm index prune \
-f quay.io/operatorhubio/catalog:latest \(1)
-p couchdb-operator,eclipse-che,etcd \(2)
[-i quay.io/openshift/origin-operator-registry:4.6.0] \(3)
-t <target_registry>:<port>/<namespace>/catalog:latest (4)
1 Index to prune. 2 Comma-separated list of packages to keep. 3 Required only for IBM Power Systems and IBM Z images: Operator Registry base image with the tag that matches the target OKD cluster major and minor version. 4 Custom tag for new index image being built. Run the following command to push the new index image to your target registry:
$ podman push <target_registry>:<port>/<namespace>/catalog:latest
where
<namespace>
is any existing namespace on the registry.
Custom catalogs using the Package Manifest Format
Building a Package Manifest Format catalog image
Cluster administrators can build a custom Operator catalog image based on the Package Manifest Format to be used by Operator Lifecycle Manager (OLM). The catalog image can be pushed to a container image registry that supports Docker v2-2. For a cluster on a restricted network, this registry can be a registry that the cluster has network access to, such as a mirror registry created during a restricted network cluster installation.
For this example, the procedure assumes use of a mirror registry that has access to both your network and the Internet.
Only the Linux version of the |
Prerequisites
Workstation with unrestricted network access
oc
version 4.3.5+ Linux clientpodman
version 1.9.3+Access to mirror registry that supports Docker v2-2
If you are working with private registries, set the
REG_CREDS
environment variable to the file path of your registry credentials for use in later steps. For example, for thepodman
CLI:$ REG_CREDS=${XDG_RUNTIME_DIR}/containers/auth.json
If you are working with private namespaces that your quay.io account has access to, you must set a Quay authentication token. Set the
AUTH_TOKEN
environment variable for use with the--auth-token
flag by making a request against the login API using your quay.io credentials:$ AUTH_TOKEN=$(curl -sH "Content-Type: application/json" \
-XPOST https://quay.io/cnr/api/v1/users/login -d '
{
"user": {
"username": "'"<quay_username>"'",
"password": "'"<quay_password>"'"
}
}' | jq -r '.token')
Procedure
On the workstation with unrestricted network access, authenticate with the target mirror registry:
$ podman login <registry_host_name>
Build a catalog image based on the
redhat-operators
catalog from Quay.io, tagging and pushing it to your mirror registry:$ oc adm catalog build \
--appregistry-org redhat-operators \(1)
--from=quay.io/openshift/origin-operator-registry:4.6.0 \(2)
--filter-by-os="linux/amd64" \(3)
--to=<registry_host_name>:<port>/olm/redhat-operators:v1 \(4)
[-a ${REG_CREDS}] \(5)
[--insecure] \(6)
[--auth-token "${AUTH_TOKEN}"] (7)
1 Organization (namespace) to pull from an App Registry instance. 2 Set —from
to the Operator Registry base image using the tag that matches the target OKD cluster major and minor version.3 Set —filter-by-os
to the operating system and architecture to use for the base image, which must match the target OKD cluster. Valid values arelinux/amd64
,linux/ppc64le
, andlinux/s390x
.4 Name your catalog image and include a tag, for example, v1
.5 Optional: If required, specify the location of your registry credentials file. 6 Optional: If you do not want to configure trust for the target registry, add the —insecure
flag.7 Optional: If other application registry catalogs are used that are not public, specify a Quay authentication token. Example output
INFO[0013] loading Bundles dir=/var/folders/st/9cskxqs53ll3wdn434vw4cd80000gn/T/300666084/manifests-829192605
...
Pushed sha256:f73d42950021f9240389f99ddc5b0c7f1b533c054ba344654ff1edaf6bf827e3 to example_registry:5000/olm/redhat-operators:v1
Sometimes invalid manifests are accidentally introduced catalogs provided by Red Hat; when this happens, you might see some errors:
Example output with errors
...
INFO[0014] directory dir=/var/folders/st/9cskxqs53ll3wdn434vw4cd80000gn/T/300666084/manifests-829192605 file=4.2 load=package
W1114 19:42:37.876180 34665 builder.go:141] error building database: error loading package into db: fuse-camel-k-operator.v7.5.0 specifies replacement that couldn't be found
Uploading ... 244.9kB/s
These errors are usually non-fatal, and if the Operator package mentioned does not contain an Operator you plan to install or a dependency of one, then they can be ignored.
Additional resources
Mirroring a Package Manifest Format catalog image
Cluster administrators can mirror a custom Operator catalog image based on the Package Manifest Format into a registry and use a catalog source to load the content onto their cluster. For this example, the procedure uses a custom redhat-operators
catalog image previously built and pushed to a supported registry.
Prerequisites
Workstation with unrestricted network access
A custom Operator catalog image based on the Package Manifest Format pushed to a supported registry
oc
version 4.3.5+podman
version 1.9.3+Access to mirror registry that supports Docker v2-2
If you are working with private registries, set the
REG_CREDS
environment variable to the file path of your registry credentials for use in later steps. For example, for thepodman
CLI:$ REG_CREDS=${XDG_RUNTIME_DIR}/containers/auth.json
Procedure
The
oc adm catalog mirror
command extracts the contents of your custom Operator catalog image to generate the manifests required for mirroring. You can choose to either:Allow the default behavior of the command to automatically mirror all of the image content to your mirror registry after generating manifests, or
Add the
--manifests-only
flag to only generate the manifests required for mirroring, but do not actually mirror the image content to a registry yet. This can be useful for reviewing what will be mirrored, and it allows you to make any changes to the mapping list if you only require a subset of the content. You can then use that file with theoc image mirror
command to mirror the modified list of images in a later step.
On your workstation with unrestricted network access, run the following command:
$ oc adm catalog mirror \
<registry_host_name>:<port>/olm/redhat-operators:v1 \(1)
<registry_host_name>:<port> \
[-a ${REG_CREDS}] \(2)
[--insecure] \(3)
[--index-filter-by-os='<platform>/<arch>'] \(4)
[--manifests-only] (5)
1 Specify your Operator catalog image. 2 Optional: If required, specify the location of your registry credentials file. 3 Optional: If you do not want to configure trust for the target registry, add the —insecure
flag.4 Optional: Specify which platform and architecture of the catalog image to select when multiple variants are available. Images are passed as ‘<platform>/<arch>[/<variant>]’
. This does not apply to images referenced by the catalog image. Valid values arelinux/amd64
,linux/ppc64le
, andlinux/s390x
.5 Optional: Only generate the manifests required for mirroring and do not actually mirror the image content to a registry. Example output
using database path mapping: /:/tmp/190214037
wrote database to /tmp/190214037
using database at: /tmp/190214037/bundles.db (1)
...
1 Temporary database generated by the command. After running the command, a
manifests-<index_image_name>-<random_number>/
directory is created in the current directory and generates the following files:The
catalogSource.yaml
file is a basic definition for aCatalogSource
object that is pre-populated with your catalog image tag and other relevant metadata. This file can be used as is or modified to add the catalog source to your cluster.The
imageContentSourcePolicy.yaml
file defines anImageContentSourcePolicy
object that can configure nodes to translate between the image references stored in Operator manifests and the mirrored registry.If your cluster uses an
ImageContentSourcePolicy
object to configure repository mirroring, you can use only global pull secrets for mirrored registries. You cannot add a pull secret to a project.The
mapping.txt
file contains all of the source images and where to map them in the target registry. This file is compatible with theoc image mirror
command and can be used to further customize the mirroring configuration.
If you used the
--manifests-only
flag in the previous step and want to mirror only a subset of the content:Modify the list of images in your
mapping.txt
file to your specifications. If you are unsure of the exact names and versions of the subset of images you want to mirror, use the following steps to find them:Run the
sqlite3
tool against the temporary database that was generated by theoc adm catalog mirror
command to retrieve a list of images matching a general search query. The output helps inform how you will later edit yourmapping.txt
file.For example, to retrieve a list of images that are similar to the string
clusterlogging.4.3
:$ echo "select * from related_image \
where operatorbundle_name like 'clusterlogging.4.3%';" \
| sqlite3 -line /tmp/190214037/bundles.db (1)
1 Refer to the previous output of the oc adm catalog mirror
command to find the path of the database file.Example output
image = registry.redhat.io/openshift4/ose-logging-kibana5@sha256:aa4a8b2a00836d0e28aa6497ad90a3c116f135f382d8211e3c55f34fb36dfe61
operatorbundle_name = clusterlogging.4.3.33-202008111029.p0
image = registry.redhat.io/openshift4/ose-oauth-proxy@sha256:6b4db07f6e6c962fc96473d86c44532c93b146bbefe311d0c348117bf759c506
operatorbundle_name = clusterlogging.4.3.33-202008111029.p0
...
Use the results from the previous step to edit the
mapping.txt
file to only include the subset of images you want to mirror.For example, you can use the
image
values from the previous example output to find that the following matching lines exist in yourmapping.txt
file:Matching image mappings in
mapping.txt
registry.redhat.io/openshift4/ose-logging-kibana5@sha256:aa4a8b2a00836d0e28aa6497ad90a3c116f135f382d8211e3c55f34fb36dfe61=<registry_host_name>:<port>/openshift4-ose-logging-kibana5:a767c8f0
registry.redhat.io/openshift4/ose-oauth-proxy@sha256:6b4db07f6e6c962fc96473d86c44532c93b146bbefe311d0c348117bf759c506=<registry_host_name>:<port>/openshift4-ose-oauth-proxy:3754ea2b
In this example, if you only want to mirror these images, you would then remove all other entries in the
mapping.txt
file and leave only the above two lines.
Still on your workstation with unrestricted network access, use your modified
mapping.txt
file to mirror the images to your registry using theoc image mirror
command:$ oc image mirror \
[-a ${REG_CREDS}] \
--filter-by-os='.*' \
-f ./manifests-redhat-operators-<random_number>/mapping.txt
If the
—filter-by-os
flag remains unset or set to any value other than.*
, the command filters out different architectures, which changes the digest of the manifest list, also known as a multi-arch image. The incorrect digest causes deployments of those images and Operators on disconnected clusters to fail.
Create the
ImageContentSourcePolicy
object:$ oc create -f ./manifests-redhat-operators-<random_number>/imageContentSourcePolicy.yaml
You can now create a CatalogSource
object to reference your mirrored content.
Additional resources
Updating a Package Manifest Format catalog image
After a cluster administrator has configured OperatorHub to use custom Operator catalog images, administrators can keep their OKD cluster up to date with the latest Operators by capturing updates made to App Registry catalogs provided by Red Hat. This is done by building and pushing a new Operator catalog image, then replacing the existing spec.image
parameter in the CatalogSource
object with the new image digest.
For this example, the procedure assumes a custom redhat-operators
catalog image is already configured for use with OperatorHub.
Only the Linux version of the |
Prerequisites
Workstation with unrestricted network access
oc
version 4.3.5+ Linux clientpodman
version 1.9.3+Access to mirror registry that supports Docker v2-2
OperatorHub configured to use custom catalog images
If you are working with private registries, set the
REG_CREDS
environment variable to the file path of your registry credentials for use in later steps. For example, for thepodman
CLI:$ REG_CREDS=${XDG_RUNTIME_DIR}/containers/auth.json
If you are working with private namespaces that your quay.io account has access to, you must set a Quay authentication token. Set the
AUTH_TOKEN
environment variable for use with the--auth-token
flag by making a request against the login API using your quay.io credentials:$ AUTH_TOKEN=$(curl -sH "Content-Type: application/json" \
-XPOST https://quay.io/cnr/api/v1/users/login -d '
{
"user": {
"username": "'"<quay_username>"'",
"password": "'"<quay_password>"'"
}
}' | jq -r '.token')
Procedure
On the workstation with unrestricted network access, authenticate with the target mirror registry:
$ podman login <registry_host_name>
Authenticate with
registry.redhat.io
so that the base image can be pulled during the build:$ podman login registry.redhat.io
Build a new catalog image based on the
redhat-operators
catalog from Quay.io, tagging and pushing it to your mirror registry:$ oc adm catalog build \
--appregistry-org redhat-operators \(1)
--from=quay.io/openshift/origin-operator-registry:4.6.0 \(2)
--filter-by-os="linux/amd64" \(3)
--to=<registry_host_name>:<port>/olm/redhat-operators:v2 \(4)
[-a ${REG_CREDS}] \(5)
[--insecure] \(6)
[--auth-token "${AUTH_TOKEN}"] (7)
1 Organization (namespace) to pull from an App Registry instance. 2 Set —from
to the Operator Registry base image using the tag that matches the target OKD cluster major and minor version.3 Set —filter-by-os
to the operating system and architecture to use for the base image, which must match the target OKD cluster. Valid values arelinux/amd64
,linux/ppc64le
, andlinux/s390x
.4 Name your catalog image and include a tag, for example, v2
because it is the updated catalog.5 Optional: If required, specify the location of your registry credentials file. 6 Optional: If you do not want to configure trust for the target registry, add the —insecure
flag.7 Optional: If other application registry catalogs are used that are not public, specify a Quay authentication token. Example output
INFO[0013] loading Bundles dir=/var/folders/st/9cskxqs53ll3wdn434vw4cd80000gn/T/300666084/manifests-829192605
...
Pushed sha256:f73d42950021f9240389f99ddc5b0c7f1b533c054ba344654ff1edaf6bf827e3 to example_registry:5000/olm/redhat-operators:v2
Mirror the contents of your catalog to your target registry. The following
oc adm catalog mirror
command extracts the contents of your custom Operator catalog image to generate the manifests required for mirroring and mirrors the images to your registry:$ oc adm catalog mirror \
<registry_host_name>:<port>/olm/redhat-operators:v2 \(1)
<registry_host_name>:<port> \
[-a ${REG_CREDS}] \(2)
[--insecure] \(3)
[--index-filter-by-os='<platform>/<arch>'] (4)
1 Specify your new Operator catalog image. 2 Optional: If required, specify the location of your registry credentials file. 3 Optional: If you do not want to configure trust for the target registry, add the —insecure
flag.4 Optional: Specify which platform and architecture of the catalog image to select when multiple variants are available. Images are passed as ‘<platform>/<arch>[/<variant>]’
. This does not apply to images referenced by the catalog image. Valid values arelinux/amd64
,linux/ppc64le
, andlinux/s390x
.Apply the newly generated manifests:
$ oc replace -f ./manifests-redhat-operators-<random_number>
It is possible that you do not need to apply the
imageContentSourcePolicy.yaml
manifest. Complete adiff
of the files to determine if changes are necessary.Update your
CatalogSource
object that references your catalog image.If you have your original
catalogsource.yaml
file for thisCatalogSource
object:Edit your
catalogsource.yaml
file to reference your new catalog image in thespec.image
field:apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: my-operator-catalog
namespace: openshift-marketplace
spec:
sourceType: grpc
image: <registry_host_name>:<port>/olm/redhat-operators:v2 (1)
displayName: My Operator Catalog
publisher: grpc
1 Specify your new Operator catalog image. Use the updated file to replace the
CatalogSource
object:$ oc replace -f catalogsource.yaml
Alternatively, edit the catalog source using the following command and reference your new catalog image in the
spec.image
parameter:$ oc edit catalogsource <catalog_source_name> -n openshift-marketplace
Updated Operators should now be available from the OperatorHub page on your OKD cluster.
Additional resources
Testing a Package Manifest Format catalog image
You can validate Operator catalog image content by running it as a container and querying its gRPC API. To further test the image, you can then resolve a subscription in Operator Lifecycle Manager (OLM) by referencing the image in a catalog source. For this example, the procedure uses a custom redhat-operators
catalog image previously built and pushed to a supported registry.
Prerequisites
A custom Package Manifest Format catalog image pushed to a supported registry
podman
version 1.9.3+oc
version 4.3.5+Access to mirror registry that supports Docker v2-2
Procedure
Pull the Operator catalog image:
$ podman pull <registry_host_name>:<port>/olm/redhat-operators:v1
Run the image:
$ podman run -p 50051:50051 \
-it <registry_host_name>:<port>/olm/redhat-operators:v1
Query the running image for available packages using
grpcurl
:$ grpcurl -plaintext localhost:50051 api.Registry/ListPackages
Example output
{
"name": "3scale-operator"
}
{
"name": "amq-broker"
}
{
"name": "amq-online"
}
Get the latest Operator bundle in a channel:
$ grpcurl -plaintext -d '{"pkgName":"kiali-ossm","channelName":"stable"}' localhost:50051 api.Registry/GetBundleForChannel
Example output
{
"csvName": "kiali-operator.v1.0.7",
"packageName": "kiali-ossm",
"channelName": "stable",
...
Get the digest of the image:
$ podman inspect \
--format='{{index .RepoDigests 0}}' \
<registry_host_name>:<port>/olm/redhat-operators:v1
Example output
example_registry:5000/olm/redhat-operators@sha256:f73d42950021f9240389f99ddc5b0c7f1b533c054ba344654ff1edaf6bf827e3
Assuming an Operator group exists in namespace
my-ns
that supports your Operator and its dependencies, create aCatalogSource
object using the image digest. For example:apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: custom-redhat-operators
namespace: my-ns
spec:
sourceType: grpc
image: example_registry:5000/olm/redhat-operators@sha256:f73d42950021f9240389f99ddc5b0c7f1b533c054ba344654ff1edaf6bf827e3
displayName: Red Hat Operators
Create a subscription that resolves the latest available
servicemeshoperator
and its dependencies from your catalog image:apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: servicemeshoperator
namespace: my-ns
spec:
source: custom-redhat-operators
sourceNamespace: my-ns
name: servicemeshoperator
channel: "1.0"
Disabling the default OperatorHub sources
Operator catalogs that source content provided by Red Hat and community projects are configured for OperatorHub by default during an OKD installation. As a cluster administrator, you can disable the set of default catalogs.
Procedure
Disable the sources for the default catalogs by adding
disableAllDefaultSources: true
to theOperatorHub
object:$ oc patch OperatorHub cluster --type json \
-p '[{"op": "add", "path": "/spec/disableAllDefaultSources", "value": true}]'
Alternatively, you can use the web console to manage catalog sources. From the Administration → Cluster Settings → Global Configuration → OperatorHub page, click the Sources tab, where you can create, delete, disable, and enable individual sources. |
Removing custom catalogs
As a cluster administrator, you can remove custom Operator catalogs that have been previously added to your cluster by deleting the related catalog source.
Procedure
In the Administrator perspective of the web console, navigate to Administration → Cluster Settings.
Click the Global Configuration tab, and then click OperatorHub.
Click the Sources tab.
Select the Options menu for the catalog that you want to remove, and then click Delete CatalogSource.