|
| 1 | +# File Based Catalog onboarding |
| 2 | + |
| 3 | +Operators in certified, marketplace, or community repositories are defined in a declarative way. |
| 4 | +This means a user provides all necessary information in advance about the operator bundle and how it |
| 5 | +should be released in a catalog and OPM automation injects a bundle into the correct place |
| 6 | +in the upgrade path. |
| 7 | + |
| 8 | +This is however very limited solution that doesn't allow any further modification of upgrade |
| 9 | +paths after a bundle is already released. Due to this limitation, a concept |
| 10 | +of FBC (File-based catalog) is now available and allows users to modify the operator upgrade |
| 11 | +path in a separate step without the need to release a new bundle. |
| 12 | + |
| 13 | +To enable FBC for a given operator the operator owner needs to convert |
| 14 | +existing operator into FBC format. |
| 15 | + |
| 16 | +We want to help with this process and we prepared a tooling that helps with this transition. |
| 17 | + |
| 18 | +## Convert existing operator to FBC |
| 19 | +As a prerequisite to this process, you need to install a few dependencies. |
| 20 | + |
| 21 | +```bash |
| 22 | +# Go to the operator repo directory (certified-operators, marketplace-operators, community-operators-prod) |
| 23 | +cd certified-operators |
| 24 | + |
| 25 | +# Install a migration script |
| 26 | +pip install git+https://github.com/redhat-openshift-ecosystem/operator-pipelines.git |
| 27 | + |
| 28 | +# Download opm cli tool |
| 29 | +curl -sL https://github.com/operator-framework/operator-registry/releases/download/v1.39.0/linux-amd64-opm -o opm && \ |
| 30 | +chmod +x opm && mv opm ~/.local/bin |
| 31 | +``` |
| 32 | + |
| 33 | +Now we can convert existing operator into FBC. The initial run takes a while because |
| 34 | +a local cache is generated during a run. |
| 35 | + |
| 36 | +The script will execute the following steps: |
| 37 | + - Fetch a list of currently supported OCP catalogs |
| 38 | + - Transform existing catalogs into a basic template |
| 39 | + - Generate a composite template for an operator |
| 40 | + - Generate an FBC catalog for a given operator |
| 41 | + - Update operator ci.yaml config |
| 42 | + |
| 43 | +The following examples will be using `aqua` operator as an example. Change an operator name that matches the operator you want to convert. |
| 44 | +```bash |
| 45 | +$ fbc-onboarding --operator-name aqua \ |
| 46 | + --repo-root . \ |
| 47 | + --verbose |
| 48 | + |
| 49 | +2024-04-24 15:53:05,537 [operator-cert] INFO Generating FBC templates for the following versions: ['4.12', '4.13', '4.14', '4.15', '4.16'] |
| 50 | +2024-04-24 15:53:07,632 [operator-cert] INFO Processing catalog: v4.12 |
| 51 | +2024-04-24 15:53:07,633 [operator-cert] DEBUG Building cache for registry.stage.redhat.io/redhat/community-operator-index:v4.12 |
| 52 | +... |
| 53 | +``` |
| 54 | + |
| 55 | +After a script is finished you should see a template and generated fbc in the repository. |
| 56 | +```bash |
| 57 | +$ tree operatos/aqua |
| 58 | + |
| 59 | +operators/aqua |
| 60 | +├── 0.0.1 |
| 61 | +... |
| 62 | +├── catalogs.yaml |
| 63 | +├── catalog-templates |
| 64 | +│ ├── v4.12.yaml |
| 65 | +│ ├── v4.13.yaml |
| 66 | +│ ├── v4.14.yaml |
| 67 | +│ ├── v4.15.yaml |
| 68 | +│ └── v4.16.yaml |
| 69 | +├── ci.yaml |
| 70 | +└── composite-config.yaml |
| 71 | +``` |
| 72 | +... and File-based catalog in `catalogs` directory |
| 73 | +```bash |
| 74 | +$ tree catalogs |
| 75 | +catalogs |
| 76 | +├── v4.12 |
| 77 | +│ └── aqua |
| 78 | +│ └── catalog.yaml |
| 79 | +├── v4.13 |
| 80 | +│ └── aqua |
| 81 | +│ └── catalog.yaml |
| 82 | +├── v4.14 |
| 83 | +│ └── aqua |
| 84 | +│ └── catalog.yaml |
| 85 | +├── v4.15 |
| 86 | +│ └── aqua |
| 87 | +│ └── catalog.yaml |
| 88 | +└── v4.16 |
| 89 | + └── aqua |
| 90 | + └── catalog.yaml |
| 91 | + |
| 92 | +``` |
| 93 | + |
| 94 | +## Submit FBC changes |
| 95 | +Artifacts generated in the previous step need to be added to a git and submitted via pull request. The operator pipeline validates the content of the catalogs and releases changes into ocp catalogs. |
| 96 | + |
| 97 | +```bash |
| 98 | +$ git add operators/aqua/{catalog-templates,catalogs.yaml,composite-config.yaml,ci.yaml} |
| 99 | + |
| 100 | +$ git add |
| 101 | +$ git add catalogs/{v4.12,v4.13,v4.14,v4.15,v4.16}/aqua |
| 102 | + |
| 103 | +$ git commit --signoff -m "Add FBC resources for aqua operator" |
| 104 | +``` |
| 105 | + |
| 106 | +## Generating catalogs from templates |
| 107 | +Catalog templates are used to simplify a view of a catalog and allow easier manipulation of catalogs. The automated conversion pre-generates a basic + composite template that can be turned into full FBC using the following command: |
| 108 | + |
| 109 | +```bash |
| 110 | +opm alpha render-template composite -f catalogs.yaml -c composite-config.yaml |
| 111 | +``` |
| 112 | + |
| 113 | +Of course, you can choose any type of template that you prefer. More information about catalog templates can be found [here](https://olm.operatorframework.io/docs/reference/catalog-templates/) |
0 commit comments