|
| 1 | +# Operator-SDK CSV generation Design Doc |
| 2 | + |
| 3 | +## Goal |
| 4 | + |
| 5 | +The `operator-sdk generate olm-catalog` sub-command should generate a [**Cluster Service Version (CSV)**](olm-csv-definition) customized using information contained in user-defined yaml manifests and Golang source files. Operator developers, *users*, should be able to run `operator-sdk generate olm-catalog` and have their operators' state encapsulated in a CSV; this command should be idempotent and only update the CSV when a yaml manifest or Golang source file is changed. Users should not have to directly interact with a CSV, and should not be required to have in-depth CSV knowledge in order for their operator to interact with [**Operator Lifecycle Manager (OLM)**](olm-description) or publish metadata to the [**Catalog**](catalog-description) |
| 6 | + |
| 7 | +## Background |
| 8 | + |
| 9 | +CSV's are yaml manifests created from a users' operator metadata that assist the OLM in running their operator in a cluster: |
| 10 | + |
| 11 | +> A CSV is the metadata that accompanies your Operator container image. It can be used to populate user interfaces with info like your logo/description/version and it is also a source of technical information needed to run the Operator, like the RBAC rules it requires and which Custom Resources it manages or depends on. |
| 12 | +
|
| 13 | +The `operator-sdk generate olm-catalog` command currently produces a generic CSV with minimal customization. Defaults and simple metadata components are used to fill fields, with no options to customize. Users must modify the CSV manually or use custom scripts to pull data from various operator component files. These solutions are not scalable because we cannot assume users are, or have time to become, familiar with CSV format or know where to find information required by CSV yaml objects. |
| 14 | + |
| 15 | +## Proposed Solution |
| 16 | + |
| 17 | +`operator-sdk generate olm-catalog` creates a `deploy` directory, which is the standard location for all manifests and scripts required to deploy an operator. This location is where users should place RBAC rules, deployments, CRD's, etc. We can leverage manifests in `deploy` to write a CSV. |
| 18 | + |
| 19 | +`operator-sdk generate olm-catalog` will call the function `renderCSV` to either: |
| 20 | + |
| 21 | +1. Create a new CSV, with the same location and naming convention as exists currently, using available data in yaml manifests and Golang source files. |
| 22 | + |
| 23 | + 1. `renderCSV` will check for an existing CSV in `deploy`. Upon not finding one, a [`ClusterServiceVersion` struct instance](olm-code-csv-struct), defined by the OLM, is created and fields easily derived from operator metadata, such as Kubernetes API `ObjectMeta`, are populated. |
| 24 | + 1. `renderCSV` will search `deploy` for manifests that contain yaml objects a CSV uses, such as a `Deployment` Kubernetes API resource, and cache found objects in a CSV struct |
| 25 | + 1. Once this search completes, every cache instance field populated will be written back to the CSV yaml file. Note that individual yaml objects are overwritten and not the entire file. |
| 26 | + |
| 27 | +1. Update an existing CSV at the currently pre-defined location, using available data in yaml manifests and Golang source files. |
| 28 | + |
| 29 | + 1. `renderCSV` will check for an existing CSV in `deploy`. Upon finding one, the CSV yaml file contents will be marshalled into a `ClusterServiceVersion` struct instance, which will act as the cache described above. |
| 30 | + 1. Same as above. |
| 31 | + 1. Same as above. |
| 32 | + |
| 33 | +## API |
| 34 | + |
| 35 | +## Reference |
| 36 | + |
| 37 | + |
| 38 | +[olm-csv-definition]: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/Documentation/design/building-your-csv.md#what-is-a-cluster-service-version-csv |
| 39 | +[olm-description]: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/README.md |
| 40 | +[catalog-description]: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/Documentation/design/architecture.md#catalog-registry-design |
| 41 | +[olm-code-csv-struct]: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/pkg/api/apis/operators/v1alpha1/clusterserviceversion_types.go |
0 commit comments