diff --git a/ships/0037-shipwright-build-strategy-controller.md b/ships/0037-shipwright-build-strategy-controller.md new file mode 100644 index 0000000..7c753be --- /dev/null +++ b/ships/0037-shipwright-build-strategy-controller.md @@ -0,0 +1,190 @@ + + +--- +title: shipwright-build-strategy-controller +authors: + - "@jkhelil" +reviewers: + - "@adambkaplan" + - "@qu1queee" +approvers: + - "@adambkaplan" + - "@qu1queee" +creation-date: 2023-10-02 +last-updated: 2023-10-02 +status: implementable +--- + +## Release Signoff Checklist + +- [x] Enhancement is `implementable` +- [x] Design details are appropriately documented from clear requirements +- [x] Test plan is defined +- [ ] Graduation criteria for dev preview, tech preview, GA +- [ ] User-facing documentation is created in [docs](/docs/) + +## Open Questions [optional] + + +## Summary + +This ship proposes support of installing a catalog of Build Strategies +via the shipwright operator in order to improve the user experience around Shipwright Build + +## Motivation + +Actually with the Shipwright operator, the user installs the Shipwright Build Controller. +Installation and upgrade of Build Strategies and Cluster Strategies is currently a manual process +In order to improve user experience around Shipwright, the operator should also install the build strategies + +### Goals + +- Create a Build Strategy catalog repository in the upstream shipwright-io organization +- Copy/publish the Build strategies from the upstream build repository to the new create catalog repository +- Allow a user to install the default Build Strategy Catalog or if applicable the user provided catalog, via the Shipwright Operator + +### Non-Goals + +- Add a new operator to install the Build Strategy catalog +- Curate or rework the Build Strategies in the upstream build repository when copied to the new catalog repository + +## Proposal + +We propose to introduce a new CRD in the Shipwright Operator : `ShipwrightBuildStrategy` API. + +```yaml +apiVersion: operator.shipwright.io/v1alpha1 +kind: ShipwrightBuildStrategy +metadata: + name: buildStrategy +spec: + targetNamespace: shipwright-build + catalog: + url: https://github.com/shipwright-io/buildstrategy-catalog +``` +We propose to add a new controller to the Shipwright Operator that reconciles the ShipwrightBuildStrategy. + + +### User Stories [optional] + +#### Story 1 + +As a Kubernetes cluster administrator +I want to be able to install the default catalog of Shipwright Builds Strategies via the Shipwright Operator +So that I can provide Shipwright Build Strategies to my developers + + +#### Story 2 + +As a Kubernetes cluster administrator +I want to be able to install , with an url I provide, my own catalog of Shipwright Builds Strategies via the Shipwright Operator +So that I can provide a custom subset of Shipwright Build Strategies to my developers + +### Implementation Notes + +#### API + +We propose to add a new custom resource the `ShipwrightBuildStrategy`. + +```yaml +apiVersion: operator.shipwright.io/v1alpha1 +kind: ShipwrightBuildStrategy +metadata: + name: buildStrategy +spec: + targetNamespace: + catalog: + url: +``` + +#### Controller + +Actually the Shipwright Operator uses controller-runtime package to bootstrap a manager +and setup the Shipwright Build controller within that manager. +In the target implementation we will continue using controller-runtime +We will split the controllers each acheiving a specific function in its own package: +- shipwrightbuild controller to reconcile ShipwrightBuild CRD and installs Shipwright Build manifests +- shipwrightbuilstrategy controller to reconcile ShipwrightBuildStrategy CRD and installs Shipwright Build Strategy catalog. +The main package will bootstrap a controller manager and adds all the controllers to the manager. +We propose this layer for package organisation + +```go +main.go +controllers + controller.go + add_shipwrightbuild.go + add_shipwrightbuildstrategy.go + shipwrightbuild + shipwrightbuild_controller.go + shipwrightbuildstragegy + shipwrightbuildstrategy_controller.go +``` + +the controller package handles the list of AddToManagerFuncs +and add to the manager any controller that register itself at package init time + +```go +// AddToManagerFuncs is a list of functions to add all Controllers to the Manager +var AddToManagerFuncs []func(manager.Manager) error + +// AddToManager adds all Controllers to the Manager +func AddToManager(m manager.Manager) error { + for _, f := range AddToManagerFuncs { + if err := f(m); err != nil { + return err + } + } + return nil +} + +``` + +add_shipwrightbuild.go contains + +```go +func init() { + // AddToManagerFuncs is a list of functions to create controllers and add them to a manager. + AddToManagerFuncs = append(AddToManagerFuncs, shipwrightbuild.Add) +} + +``` + +add_shipwrightbuildstrategy.go contains + +```go +func init() { + // AddToManagerFuncs is a list of functions to create controllers and add them to a manager. + AddToManagerFuncs = append(AddToManagerFuncs, shipwrightbuildstrategy.Add) +} + +``` + +### Test Plan + +The implementation has to be tested on a `unit`, `integration` and `e2e` level to ensure correctness. + +### Release Criteria + +tbd + +### Risks and Mitigations + +The default strategy catalog or any url provided catalog can be unreachable if the kubernetes cluster needs +- a proxy to access to the catalog url +- it is a disconnected cluster and doesnt have any access to internet + +## Drawbacks + + +## Alternatives + + +## Infrastructure Needed [optional] + + +## Implementation History +