Skip to content

Use ko to render full image specifications into the operator bundle image #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

adambkaplan
Copy link
Member

@adambkaplan adambkaplan commented Apr 20, 2022

Changes

  • Move main.go to top-level, to conform with Kubebuilder v3 project
    format.
  • Replace image references with ko replacements
  • Remove kustomization that overrides image name and tag.
  • Add containerImage to CSV base, using ko reference.
  • Update Makefile to deploy operator directly with ko.
  • Update Makefile to render the operator bundle CSV with ko.
  • Update Makefile to have installation of ko idempotent.
  • Update Makefile to deploy operator directly with ko.
  • Update Makefile to have installation of ko idempotent.
  • Update make bundle-build to build the OLM bundle in an output
    directory, using ko resolve to render the true CSV.
  • Update make bundle push to also push the operator image.
  • Update CI and release script to only run make bundle-push.
  • Update development docs to drop references to make ko-publish.
  • Print diff if check-git-status fails.

Fixes #48

/kind feature

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Set a kind label on this PR
  • Release notes block has been filled in, or marked NONE

See the contributor guide
for details on coding conventions, github and prow interactions, and the code review process.

Release Notes

Use ko to render full image specifications into the operator bundle image. Add the `containerImage` annotation to the operator's CSV.

@openshift-ci openshift-ci bot added release-note do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. labels Apr 20, 2022
@openshift-ci openshift-ci bot requested review from gabemontero and imjasonh April 20, 2022 18:47
# Format for the SBOM produced by ko.
# Defaults to "spdx", use "none" to disable SBOM generation
SBOM ?= "spdx"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ko may change its default ~soon, to either cyclonedx, or (more likely) both. Just something to keep in mind here.

cp -r bundle _output/olm/
cp bundle.Dockerfile _output/olm/
KO_DOCKER_REPO=${IMAGE_REPO} $(KO) resolve --push=${IMAGE_PUSH} ${KO_OPTS} -f ${OPERATOR_CSV} > _output/olm/${OPERATOR_CSV}
$(CONTAINER_ENGINE) build -f _output/olm/bundle.Dockerfile -t $(BUNDLE_IMG) _output/olm

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sad that OLM undoes ko's hard work and requires a container runtime to make this bundle. Without knowing much about it I'd guess it's entirely unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't undo ko's hard work, per se. The bundle is just YAML in an OCI artifact, which are updated with the ko resolved image shas. A full runtime like docker/podman is indeed overkill, but in terms of what developers reasonably have available, the decision makes sense.

- Move main.go to top-level, to conform with Kubebuilder v3 project
  format.
- Replace image references with ko replacements
- Remove kustomization that overrides image name and tag.
- Add containerImage to CSV, using ko reference.
- Update Makefile to deploy operator directly with ko.
- Update Makefile to have installation of ko idempotent.
- Update `make bundle-build` to build the OLM bundle in an output
  directory, using `ko resolve` to render the true CSV.
- Update `make bundle push` to also push the operator image.
- Update CI and release script to only run `make bundle-push`.
- Update development docs to drop references to `make ko-publish`.
- Print diff if check-git-status fails.
@adambkaplan adambkaplan changed the title WIP - Use ko to deploy operator and bundle Use ko to render full image specifications into the operator bundle image Apr 22, 2022
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 22, 2022
@adambkaplan
Copy link
Member Author

One thing that this change can enable is nightly/latest releases for the operator! Since the bundle in git doesn't need to be changed for us to build a new bundle image, we can cut operator releases with a floating tag that respects semver.

@adambkaplan
Copy link
Member Author

/assign @otaviof

/cc @imjasonh

@openshift-ci openshift-ci bot requested a review from imjasonh April 22, 2022 09:58
@adambkaplan
Copy link
Member Author

/approve

Self-approving

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 25, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adambkaplan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 25, 2022
Copy link
Member

@otaviof otaviof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Thanks for the detailed documentation!

Comment on lines +24 to +25
Using `ko.local` or `kind.local` for `IMAGE_REPO` is not recommended, as this will not push the
resulting images to an OCI-compliant container registry.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an interesting behavior, @adambkaplan. I find the ko approach to kind.local registries very useful, but for OLM we really need OCI compliance.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, found this the hard way when building the CI infra for the operator in the first place. Deploying an operator on OLM requires at minimum 3 container images:

  1. The operator binary
  2. The operator "bundle"
  3. The catalog source

Item 3 needs to be pullable from a container registry. I think item 2 must also be pullable from a container registry. In terms of dev/testing, pushing everything to a "real" registry just makes life easier.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 27, 2022
@openshift-merge-robot openshift-merge-robot merged commit 2a3fdbe into shipwright-io:main Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OperatorHub requires containerImage annotation
4 participants