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

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

  1. Start a new index:

    1. $ opm index add \
    2. --bundles <registry>/<namespace>/<bundle_image_name>:<tag> \(1)
    3. --tag <registry>/<namespace>/<index_image_name>:<tag> \(2)
    4. [--binary-image <registry_base_image>] (3)
    1Comma-separated list of bundle images to add to the index.
    2The image tag that you want the index image to have.
    3Optional: An alternative registry base image to use for serving the catalog.
  2. Push the index image to a registry.

    1. If required, authenticate with your target registry:

      1. $ podman login <registry>
    2. Push the index image:

      1. $ 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

  1. Create a CatalogSource object that references your index image.

    1. Modify the following to your specifications and save it as a catalogSource.yaml file:

      1. apiVersion: operators.coreos.com/v1alpha1
      2. kind: CatalogSource
      3. metadata:
      4. name: my-operator-catalog
      5. namespace: olm (1)
      6. spec:
      7. sourceType: grpc
      8. image: <registry>:<port>/<namespace>/catalog:latest (2)
      9. displayName: My Operator Catalog
      10. publisher: <publisher_name> (3)
      11. updateStrategy:
      12. registryPoll: (4)
      13. interval: 30m
      1If 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.
      2Specify your index image.
      3Specify your name or an organization name publishing the catalog.
      4Catalog sources can automatically check for new versions to keep up to date.
    2. Use the file to create the CatalogSource object:

      1. $ oc apply -f catalogSource.yaml
  2. Verify the following resources are created successfully.

    1. Check the pods:

      1. $ oc get pods -n olm

      Example output

      1. NAME READY STATUS RESTARTS AGE
      2. my-operator-catalog-6njx6 1/1 Running 0 28s
      3. marketplace-operator-d9f549946-96sgr 1/1 Running 0 26h
    2. Check the catalog source:

      1. $ oc get catalogsource -n olm

      Example output

      1. NAME DISPLAY TYPE PUBLISHER AGE
      2. my-operator-catalog My Operator Catalog grpc 5s
    3. Check the package manifest:

      1. $ oc get packagemanifest -n olm

      Example output

      1. NAME CATALOG AGE
      2. jaeger-product My Operator Catalog 93s

You can now install the Operators from the OperatorHub page on your OKD web console.

Additional resources

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

  1. Update the existing index by adding bundle images:

    1. $ opm index add \
    2. --bundles <registry>/<namespace>/<new_bundle_image>:<tag> \(1)
    3. --from-index <registry>/<namespace>/<existing_index_image>:<tag> \(2)
    4. --tag <registry>/<namespace>/<existing_index_image>:<tag> (3)
    1A comma-separated list of additional bundle images to add to the index.
    2The existing index that was previously pushed.
    3The image tag that you want the updated index image to have.
  2. Push the updated index image:

    1. $ podman push <registry>/<namespace>/<existing_index_image>:<tag>
  3. 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:

    1. $ 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+

  • grpcurl

  • opm version 1.12.3+

  • Access to a registry that supports Docker v2-2

Procedure

  1. Authenticate with your target registry:

    1. $ podman login <target_registry>
  2. Determine the list of packages you want to include in your pruned index.

    1. Run the source index image that you want to prune in a container. For example:

      1. $ podman run -p50051:50051 \
      2. -it quay.io/operatorhubio/catalog:latest

      Example output

      1. Trying to pull quay.io/operatorhubio/catalog:latest...
      2. Getting image source signatures
      3. Copying blob ae8a0c23f5b1 done
      4. ...
      5. INFO[0000] serving registry database=/database/index.db port=50051
    2. In a separate terminal session, use the grpcurl command to get a list of the packages provided by the index:

      1. $ grpcurl -plaintext localhost:50051 api.Registry/ListPackages > packages.out
    3. 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

      1. ...
      2. {
      3. "name": "couchdb-operator"
      4. }
      5. ...
      6. {
      7. "name": "eclipse-che"
      8. }
      9. ...
      10. {
      11. {
      12. "name": "etcd"
      13. }
      14. ...
    4. In the terminal session where you executed the podman run command, press Ctrl and C to stop the container process.

  3. Run the following command to prune the source index of all but the specified packages:

    1. $ opm index prune \
    2. -f quay.io/operatorhubio/catalog:latest \(1)
    3. -p couchdb-operator,eclipse-che,etcd \(2)
    4. [-i quay.io/openshift/origin-operator-registry:4.7.0] \(3)
    5. -t <target_registry>:<port>/<namespace>/catalog:latest (4)
    1Index to prune.
    2Comma-separated list of packages to keep.
    3Required 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.
    4Custom tag for new index image being built.
  4. Run the following command to push the new index image to your target registry:

    1. $ 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 oc client can be used for this procedure, because the Windows and macOS versions do not provide the oc adm catalog build command.

Prerequisites

  • Workstation with unrestricted network access

  • oc version 4.3.5+ Linux client

  • 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 the podman CLI:

    1. $ 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:

    1. $ AUTH_TOKEN=$(curl -sH "Content-Type: application/json" \
    2. -XPOST https://quay.io/cnr/api/v1/users/login -d '
    3. {
    4. "user": {
    5. "username": "'"<quay_username>"'",
    6. "password": "'"<quay_password>"'"
    7. }
    8. }' | jq -r '.token')

Procedure

  1. On the workstation with unrestricted network access, authenticate with the target mirror registry:

    1. $ podman login <registry_host_name>
  2. Build a catalog image based on the redhat-operators catalog from Quay.io, tagging and pushing it to your mirror registry:

    1. $ oc adm catalog build \
    2. --appregistry-org redhat-operators \(1)
    3. --from=quay.io/openshift/origin-operator-registry:4.7.0 \(2)
    4. --filter-by-os="linux/amd64" \(3)
    5. --to=<registry_host_name>:<port>/olm/redhat-operators:v1 \(4)
    6. [-a ${REG_CREDS}] \(5)
    7. [--insecure] \(6)
    8. [--auth-token "${AUTH_TOKEN}"] (7)
    1Organization (namespace) to pull from an App Registry instance.
    2Set —from to the Operator Registry base image using the tag that matches the target OKD cluster major and minor version.
    3Set —filter-by-os to the operating system and architecture to use for the base image, which must match the target OKD cluster. Valid values are linux/amd64, linux/ppc64le, and linux/s390x.
    4Name your catalog image and include a tag, for example, v1.
    5Optional: If required, specify the location of your registry credentials file.
    6Optional: If you do not want to configure trust for the target registry, add the —insecure flag.
    7Optional: If other application registry catalogs are used that are not public, specify a Quay authentication token.

    Example output

    1. INFO[0013] loading Bundles dir=/var/folders/st/9cskxqs53ll3wdn434vw4cd80000gn/T/300666084/manifests-829192605
    2. ...
    3. 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

    1. ...
    2. INFO[0014] directory dir=/var/folders/st/9cskxqs53ll3wdn434vw4cd80000gn/T/300666084/manifests-829192605 file=4.2 load=package
    3. 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
    4. 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 the podman CLI:

    1. $ REG_CREDS=${XDG_RUNTIME_DIR}/containers/auth.json

Procedure

  1. 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 the oc 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:

    1. $ oc adm catalog mirror \
    2. <registry_host_name>:<port>/olm/redhat-operators:v1 \(1)
    3. <registry_host_name>:<port> \
    4. [-a ${REG_CREDS}] \(2)
    5. [--insecure] \(3)
    6. [--index-filter-by-os='<platform>/<arch>'] \(4)
    7. [--manifests-only] (5)
    1Specify your Operator catalog image.
    2Optional: If required, specify the location of your registry credentials file.
    3Optional: If you do not want to configure trust for the target registry, add the —insecure flag.
    4Optional: 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 are linux/amd64, linux/ppc64le, and linux/s390x.
    5Optional: Only generate the manifests required for mirroring and do not actually mirror the image content to a registry.

    Example output

    1. using database path mapping: /:/tmp/190214037
    2. wrote database to /tmp/190214037
    3. using database at: /tmp/190214037/bundles.db (1)
    4. ...
    1Temporary 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 a CatalogSource 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 an ImageContentSourcePolicy 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 the oc image mirror command and can be used to further customize the mirroring configuration.

  2. If you used the --manifests-only flag in the previous step and want to mirror only a subset of the content:

    1. 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:

      1. Run the sqlite3 tool against the temporary database that was generated by the oc adm catalog mirror command to retrieve a list of images matching a general search query. The output helps inform how you will later edit your mapping.txt file.

        For example, to retrieve a list of images that are similar to the string clusterlogging.4.3:

        1. $ echo "select * from related_image \
        2. where operatorbundle_name like 'clusterlogging.4.3%';" \
        3. | sqlite3 -line /tmp/190214037/bundles.db (1)
        1Refer to the previous output of the oc adm catalog mirror command to find the path of the database file.

        Example output

        1. image = registry.redhat.io/openshift-logging/kibana6-rhel8@sha256:aa4a8b2a00836d0e28aa6497ad90a3c116f135f382d8211e3c55f34fb36dfe61
        2. operatorbundle_name = clusterlogging.4.3.33-202008111029.p0
        3. image = registry.redhat.io/openshift4/ose-oauth-proxy@sha256:6b4db07f6e6c962fc96473d86c44532c93b146bbefe311d0c348117bf759c506
        4. operatorbundle_name = clusterlogging.4.3.33-202008111029.p0
        5. ...
      2. 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 your mapping.txt file:

        Matching image mappings in mapping.txt

        1. registry.redhat.io/openshift-logging/kibana6-rhel8@sha256:aa4a8b2a00836d0e28aa6497ad90a3c116f135f382d8211e3c55f34fb36dfe61=<registry_host_name>:<port>/kibana6-rhel8:a767c8f0
        2. 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.

    2. Still on your workstation with unrestricted network access, use your modified mapping.txt file to mirror the images to your registry using the oc image mirror command:

      1. $ oc image mirror \
      2. [-a ${REG_CREDS}] \
      3. --filter-by-os='.*' \
      4. -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.

  3. Create the ImageContentSourcePolicy object:

    1. $ 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 oc client can be used for this procedure, because the Windows and macOS versions do not provide the oc adm catalog build command.

Prerequisites

  • Workstation with unrestricted network access

  • oc version 4.3.5+ Linux client

  • podman 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 the podman CLI:

    1. $ 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:

    1. $ AUTH_TOKEN=$(curl -sH "Content-Type: application/json" \
    2. -XPOST https://quay.io/cnr/api/v1/users/login -d '
    3. {
    4. "user": {
    5. "username": "'"<quay_username>"'",
    6. "password": "'"<quay_password>"'"
    7. }
    8. }' | jq -r '.token')

Procedure

  1. On the workstation with unrestricted network access, authenticate with the target mirror registry:

    1. $ podman login <registry_host_name>
  2. Authenticate with registry.redhat.io so that the base image can be pulled during the build:

    1. $ podman login registry.redhat.io
  3. Build a new catalog image based on the redhat-operators catalog from Quay.io, tagging and pushing it to your mirror registry:

    1. $ oc adm catalog build \
    2. --appregistry-org redhat-operators \(1)
    3. --from=quay.io/openshift/origin-operator-registry:4.7.0 \(2)
    4. --filter-by-os="linux/amd64" \(3)
    5. --to=<registry_host_name>:<port>/olm/redhat-operators:v2 \(4)
    6. [-a ${REG_CREDS}] \(5)
    7. [--insecure] \(6)
    8. [--auth-token "${AUTH_TOKEN}"] (7)
    1Organization (namespace) to pull from an App Registry instance.
    2Set —from to the Operator Registry base image using the tag that matches the target OKD cluster major and minor version.
    3Set —filter-by-os to the operating system and architecture to use for the base image, which must match the target OKD cluster. Valid values are linux/amd64, linux/ppc64le, and linux/s390x.
    4Name your catalog image and include a tag, for example, v2 because it is the updated catalog.
    5Optional: If required, specify the location of your registry credentials file.
    6Optional: If you do not want to configure trust for the target registry, add the —insecure flag.
    7Optional: If other application registry catalogs are used that are not public, specify a Quay authentication token.

    Example output

    1. INFO[0013] loading Bundles dir=/var/folders/st/9cskxqs53ll3wdn434vw4cd80000gn/T/300666084/manifests-829192605
    2. ...
    3. Pushed sha256:f73d42950021f9240389f99ddc5b0c7f1b533c054ba344654ff1edaf6bf827e3 to example_registry:5000/olm/redhat-operators:v2
  4. 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:

    1. $ oc adm catalog mirror \
    2. <registry_host_name>:<port>/olm/redhat-operators:v2 \(1)
    3. <registry_host_name>:<port> \
    4. [-a ${REG_CREDS}] \(2)
    5. [--insecure] \(3)
    6. [--index-filter-by-os='<platform>/<arch>'] (4)
    1Specify your new Operator catalog image.
    2Optional: If required, specify the location of your registry credentials file.
    3Optional: If you do not want to configure trust for the target registry, add the —insecure flag.
    4Optional: 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 are linux/amd64, linux/ppc64le, and linux/s390x.
  5. Apply the newly generated manifests:

    1. $ oc replace -f ./manifests-redhat-operators-<random_number>

    It is possible that you do not need to apply the imageContentSourcePolicy.yaml manifest. Complete a diff of the files to determine if changes are necessary.

  6. Update your CatalogSource object that references your catalog image.

    1. If you have your original catalogsource.yaml file for this CatalogSource object:

      1. Edit your catalogsource.yaml file to reference your new catalog image in the spec.image field:

        1. apiVersion: operators.coreos.com/v1alpha1
        2. kind: CatalogSource
        3. metadata:
        4. name: my-operator-catalog
        5. namespace: openshift-marketplace
        6. spec:
        7. sourceType: grpc
        8. image: <registry_host_name>:<port>/olm/redhat-operators:v2 (1)
        9. displayName: My Operator Catalog
        10. publisher: grpc
        1Specify your new Operator catalog image.
      2. Use the updated file to replace the CatalogSource object:

        1. $ oc replace -f catalogsource.yaml
    2. Alternatively, edit the catalog source using the following command and reference your new catalog image in the spec.image parameter:

      1. $ 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

  • grpcurl

Procedure

  1. Pull the Operator catalog image:

    1. $ podman pull <registry_host_name>:<port>/olm/redhat-operators:v1
  2. Run the image:

    1. $ podman run -p 50051:50051 \
    2. -it <registry_host_name>:<port>/olm/redhat-operators:v1
  3. Query the running image for available packages using grpcurl:

    1. $ grpcurl -plaintext localhost:50051 api.Registry/ListPackages

    Example output

    1. {
    2. "name": "3scale-operator"
    3. }
    4. {
    5. "name": "amq-broker"
    6. }
    7. {
    8. "name": "amq-online"
    9. }
  4. Get the latest Operator bundle in a channel:

    1. $ grpcurl -plaintext -d '{"pkgName":"kiali-ossm","channelName":"stable"}' localhost:50051 api.Registry/GetBundleForChannel

    Example output

    1. {
    2. "csvName": "kiali-operator.v1.0.7",
    3. "packageName": "kiali-ossm",
    4. "channelName": "stable",
    5. ...
  5. Get the digest of the image:

    1. $ podman inspect \
    2. --format='{{index .RepoDigests 0}}' \
    3. <registry_host_name>:<port>/olm/redhat-operators:v1

    Example output

    1. example_registry:5000/olm/redhat-operators@sha256:f73d42950021f9240389f99ddc5b0c7f1b533c054ba344654ff1edaf6bf827e3
  6. Assuming an Operator group exists in namespace my-ns that supports your Operator and its dependencies, create a CatalogSource object using the image digest. For example:

    1. apiVersion: operators.coreos.com/v1alpha1
    2. kind: CatalogSource
    3. metadata:
    4. name: custom-redhat-operators
    5. namespace: my-ns
    6. spec:
    7. sourceType: grpc
    8. image: example_registry:5000/olm/redhat-operators@sha256:f73d42950021f9240389f99ddc5b0c7f1b533c054ba344654ff1edaf6bf827e3
    9. displayName: Red Hat Operators
  7. Create a subscription that resolves the latest available servicemeshoperator and its dependencies from your catalog image:

    1. apiVersion: operators.coreos.com/v1alpha1
    2. kind: Subscription
    3. metadata:
    4. name: servicemeshoperator
    5. namespace: my-ns
    6. spec:
    7. source: custom-redhat-operators
    8. sourceNamespace: my-ns
    9. name: servicemeshoperator
    10. channel: "1.0"

Accessing images for Operators from private registries

If certain images relevant to Operators managed by Operator Lifecycle Manager (OLM) are hosted in an authenticated container image registry, also known as a private registry, OLM and OperatorHub are unable to pull the images by default. To enable access, you can create a pull secret that contains the authentication credentials for the registry. By referencing one or more pull secrets in a catalog source, OLM can handle placing the secrets in the Operator and catalog namespace to allow installation.

Other images required by an Operator or its Operands might require access to private registries as well. OLM does not handle placing the secrets in target tenant namespaces for this scenario, but authentication credentials can be added to the global cluster pull secret or individual namespace service accounts to enable the required access.

The following types of images should be considered when determining whether Operators managed by OLM have appropriate pull access:

Index or catalog images

A CatalogSource object can reference an index image or a catalog image, which are catalog sources packaged as container images hosted in images registries. Index images use the Bundle Format and reference bundle images, while catalog images use the Package Manifest Format. If an index or catalog image is hosted in a private registry, a secret can be used to enable pull access.

Bundle images

Operator bundle images are metadata and manifests packaged as container images that represent a unique version of an Operator. If any bundle images referenced in a catalog source are hosted in one or more private registries, a secret can be used to enable pull access.

Operator and Operand images

If an Operator installed from a catalog source uses a private image, either for the Operator image itself or one of the Operand images it watches, the Operator will fail to install because the deployment will not have access to the required registry authentication. Referencing secrets in a catalog source does not enable OLM to place the secrets in target tenant namespaces in which Operands are installed.

Instead, the authentication details can be added to the global cluster pull secret in the openshift-config namespace, which provides access to all namespaces on the cluster. Alternatively, if providing access to the entire cluster is not permissible, the pull secret can be added to the default service accounts of the target tenant namespaces.

Prerequisites

  • At least one of the following hosted in a private registry:

    • An index image or catalog image.

    • An Operator bundle image.

    • An Operator or Operand image.

Procedure

  1. Create a secret for each required private registry.

    1. Log in to the private registry to create or update your registry credentials file:

      1. $ podman login <registry>:<port>

      The file path of your registry credentials can be different depending on the container tool used to log in to the registry. For the podman CLI, the default location is ${XDG_RUNTIME_DIR}/containers/auth.json. For the docker CLI, the default location is /root/.docker/config.json.

    2. It is recommended to include credentials for only one registry per secret, and manage credentials for multiple registries in separate secrets. Multiple secrets can be included in a CatalogSource object in later steps, and OKD will merge the secrets into a single virtual credentials file for use during an image pull.

      A registry credentials file can, by default, store details for more than one registry. Verify the current contents of your file. For example:

      File storing credentials for two registries

      1. {
      2. "auths": {
      3. "registry.redhat.io": {
      4. "auth": "FrNHNydQXdzclNqdg=="
      5. },
      6. "quay.io": {
      7. "auth": "Xd2lhdsbnRib21iMQ=="
      8. }
      9. }
      10. }

      Because this file is used to create secrets in later steps, ensure that you are storing details for only one registry per file. This can be accomplished by using either of the following methods:

      • Use the podman logout <registry> command to remove credentials for additional registries until only the one registry you want remains.

      • Edit your registry credentials file and separate the registry details to be stored in multiple files. For example:

        File storing credentials for one registry

        1. {
        2. "auths": {
        3. "registry.redhat.io": {
        4. "auth": "FrNHNydQXdzclNqdg=="
        5. }
        6. }
        7. }

        File storing credentials for another registry

        1. {
        2. "auths": {
        3. "quay.io": {
        4. "auth": "Xd2lhdsbnRib21iMQ=="
        5. }
        6. }
        7. }
    3. Create a secret in the openshift-marketplace namespace that contains the authentication credentials for a private registry:

      1. $ oc create secret generic <secret_name> \
      2. -n openshift-marketplace \
      3. --from-file=.dockerconfigjson=<path/to/registry/credentials> \
      4. --type=kubernetes.io/dockerconfigjson

      Repeat this step to create additional secrets for any other required private registries, updating the --from-file flag to specify another registry credentials file path.

  2. Create or update an existing CatalogSource object to reference one or more secrets:

    1. apiVersion: operators.coreos.com/v1alpha1
    2. kind: CatalogSource
    3. metadata:
    4. name: my-operator-catalog
    5. namespace: openshift-marketplace
    6. spec:
    7. sourceType: grpc
    8. secrets: (1)
    9. - "<secret_name_1>"
    10. - "<secret_name_2>"
    11. image: <registry>:<port>/<namespace>/<image>:<tag>
    12. displayName: My Operator Catalog
    13. publisher: <publisher_name>
    14. updateStrategy:
    15. registryPoll:
    16. interval: 30m
    1Add a spec.secrets section and specify any required secrets.
  3. If any Operator or Operand images that are referenced by a subscribed Operator require access to a private registry, you can either provide access to all namespaces in the cluster, or individual target tenant namespaces.

    • To provide access to all namespaces in the cluster, add authentication details to the global cluster pull secret in the openshift-config namespace.

      Cluster resources must adjust to the new global pull secret, which can temporarily limit the usability of the cluster.

      1. Extract the .dockerconfigjson file from the global pull secret:

        1. $ oc extract secret/pull-secret -n openshift-config --confirm
      2. Update the .dockerconfigjson file with your authentication credentials for the required private registry or registries and save it as a new file:

        1. $ cat .dockerconfigjson | \
        2. jq --compact-output '.auths["<registry>:<port>/<namespace>/"] |= . + {"auth":"<token>"}' \(1)
        3. > new_dockerconfigjson
        1Replace <registry>:<port>/<namespace> with the private registry details and <token> with your authentication credentials.
      3. Update the global pull secret with the new file:

        1. $ oc set data secret/pull-secret -n openshift-config \
        2. --from-file=.dockerconfigjson=new_dockerconfigjson
    • To update an individual namespace, add a pull secret to the service account for the Operator that requires access in the target tenant namespace.

      1. Recreate the secret that you created for the openshift-marketplace in the tenant namespace:

        1. $ oc create secret generic <secret_name> \
        2. -n <tenant_namespace> \
        3. --from-file=.dockerconfigjson=<path/to/registry/credentials> \
        4. --type=kubernetes.io/dockerconfigjson
      2. Verify the name of the service account for the Operator by searching the tenant namespace:

        1. $ oc get sa -n <tenant_namespace> (1)
        1If the Operator was installed in an individual namespace, search that namespace. If the Operator was installed for all namespaces, search the openshift-operators namespace.

        Example output

        1. NAME SECRETS AGE
        2. builder 2 6m1s
        3. default 2 6m1s
        4. deployer 2 6m1s
        5. etcd-operator 2 5m18s (1)
        1Service account for an installed etcd Operator.
      3. Link the secret to the service account for the Operator:

        1. $ oc secrets link <operator_sa> \
        2. -n <tenant_namespace> \
        3. <secret_name> \
        4. --for=pull

Additional resources

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 the OperatorHub object:

    1. $ oc patch OperatorHub cluster --type json \
    2. -p '[{"op": "add", "path": "/spec/disableAllDefaultSources", "value": true}]'

Alternatively, you can use the web console to manage catalog sources. From the AdministrationCluster SettingsGlobal ConfigurationOperatorHub 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

  1. In the Administrator perspective of the web console, navigate to AdministrationCluster Settings.

  2. Click the Global Configuration tab, and then click OperatorHub.

  3. Click the Sources tab.

  4. Select the Options menu kebab for the catalog that you want to remove, and then click Delete CatalogSource.