Understanding OpenShift CagalogSource Image

The CatalogSource is the definition of a source that contains bundles (packages) that we can install on our cluster, in the CatalogSource definition, there is a pointer to the index image,

e.g let’s examine the Redhat Catalog in OpenShift

    oc get CatalogSource/redhat-marketplace -n openshift-marketplace -o yaml
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
  annotations:
    operatorframework.io/managed-by: marketplace-operator
    operatorframework.io/priorityclass: system-cluster-critical
    target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
  generation: 1
  name: redhat-operators
  namespace: openshift-marketplace
spec:
  displayName: Red Hat Operators
  icon:
    base64data: ""
    mediatype: ""
  image: registry.redhat.io/redhat/redhat-operator-index:v4.9
  priority: -100
  publisher: Red Hat
  sourceType: grpc
  updateStrategy:
    registryPoll:
      interval: 10m0s

So we can see that the above CatalogSource points to `registry.redhat.io/redhat/redhat-marketplace-index:v4.9`

This index image contains a file under `/database/index.db` which is an SQLite DB file.

Let us pull it down and see what we have inside of it.

    oc image extract registry.redhat.io/redhat/redhat-operator-index:v4.9 --file /database/index.db -a ./pull-secret.json
$ sqlite3 index.db
SQLite version 3.36.0 2021-06-18 18:36:39
Enter ".help" for usage hints.
sqlite> .tables
api                channel            deprecated         properties
api_provider       channel_entry      operatorbundle     related_image
api_requirer       dependencies       package            schema_migrations

One of the tables is `operatorbundle`, let us dig a bit inside of it, for simplicity let’s focus on a single operator we like to investigate,

    select name,bundlepath,skiprange,version from operatorbundle where name like "local-%";
|name                                      | bundlepath                                                                                                                              | skiprange                   | version           |
|------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|-------------------|
|local-storage-operator.4.9.0-202202120107 | registry.redhat.io/openshift4/ose-local-storage-operator-bundle@sha256:b392e1d7812156b467133cb8167e250767e19a6fbdf64b8da2850bcabc73d2fe | >=4.3.0 <4.9.0-202202120107 | 4.9.0-202202120107|
|local-storage-operator.4.9.0-202203081819 | registry.redhat.io/openshift4/ose-local-storage-operator-bundle@sha256:b51252453893075e4c9fc3dc1c10a0a047f89a184ff530d11883b13faa50e0dd | >=4.3.0 <4.9.0-202203081819 | 4.9.0-202203081819|
|local-storage-operator.4.9.0-202203120157 | registry.redhat.io/openshift4/ose-local-storage-operator-bundle@sha256:52386de1a4aa7de530e8d152cac0702ed440bf2e67f9645269042c1b7544e7b7 | >=4.3.0 <4.9.0-202203120157 | 4.9.0-202203120157|
|local-storage-operator.4.9.0-202203150126 | registry.redhat.io/openshift4/ose-local-storage-operator-bundle@sha256:29cea0462ae9f9fd1ecbb2419013f24026fed4c25ef7ccbb3ac0e332fc923549 | >=4.3.0 <4.9.0-202203150126 | 4.9.0-202203150126|

As we can see the `local-storage-operator` has 4 lines in this DB, with each version pointing to another image, so how can we know which version to install?

In the `channel` table we have the “pointer” we are looking for

    select package_name, name, head_operatorbundle_name from channel where package_name like "local%";
|package_name           | name   | head_operatorbundle_name                 |
|-----------------------|--------|------------------------------------------|
|local-storage-operator | 4.9    | local-storage-operator.4.9.0-202203150126|
|local-storage-operator | stable | local-storage-operator.4.9.0-202203150126|

As we can see the `local-storage-operator` has 2 channels `stable` and `4.9` and they both point to the same bundle `local-storage-operator.4.9.0-202203150126`

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *