Skip to content

Commit

Permalink
Use operator-sdk/opm for bundling
Browse files Browse the repository at this point in the history
Fixes #73
  • Loading branch information
andrewazores committed Feb 24, 2020
1 parent a64f146 commit 25508e4
Show file tree
Hide file tree
Showing 17 changed files with 1,332 additions and 276 deletions.
75 changes: 58 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
IMAGE_TAG ?= quay.io/rh-jmc-team/container-jfr-operator:0.3.0
CRDS := containerjfr flightrecorder
IMAGE_STREAM ?= quay.io/rh-jmc-team/container-jfr-operator
IMAGE_VERSION ?= 0.3.3
IMAGE_TAG ?= $(IMAGE_STREAM):$(IMAGE_VERSION)

BUNDLE_STREAM ?= $(IMAGE_STREAM)-bundle
CSV_VERSION ?= 0.3.3
PREV_CSV_VERSION ?= $(CSV_VERSION)

INDEX_STREAM ?= $(IMAGE_STREAM)-index
INDEX_VERSION ?= 0.0.1
PREV_INDEX_VERSION ?= $(INDEX_VERSION)

BUILDER ?= podman

.DEFAULT_GOAL := bundle

Expand All @@ -14,17 +25,51 @@ k8s:
crds:
operator-sdk generate crds

.PHONY: csv
csv:
# TODO
# from-version should be programatically determined
operator-sdk generate csv \
--from-version $(PREV_CSV_VERSION) \
--csv-config ./deploy/olm-catalog/csv-config.yaml \
--csv-version $(CSV_VERSION) \
--csv-channel alpha \
--default-channel \
--update-crds \
--operator-name container-jfr-operator-bundle

.PHONY: image
image: generate
operator-sdk build --image-builder podman $(IMAGE_TAG)
operator-sdk build --image-builder $(BUILDER) $(IMAGE_TAG)

.PHONY: bundle
bundle: image copy-crds
operator-courier verify --ui_validate_io bundle

.PHONY: copy-crds
copy-crds:
$(foreach res, $(CRDS), cp -f deploy/crds/rhjmc.redhat.com_$(res)s_crd.yaml bundle/$(res)s.rhjmc.redhat.com.crd.yaml;)
bundle:
operator-sdk bundle create \
$(BUNDLE_STREAM):$(CSV_VERSION) \
--image-builder $(BUILDER) \
--directory ./deploy/olm-catalog/container-jfr-operator-bundle/$(CSV_VERSION) \
--default-channel alpha \
--channels alpha \
--package container-jfr-operator-bundle

.PHONY: validate
validate: verify-csv
operator-sdk bundle validate \
--image-builder $(BUILDER) \
$(IMAGE_TAG)

.PHONY: verify-csv
verify-csv:
operator-courier verify deploy/olm-catalog/container-jfr-operator-bundle

.PHONY: index
index:
# TODO
# previous index version should be programatically determined
opm index add \
--from-index $(INDEX_STREAM):$(PREV_INDEX_VERSION) \
--bundles $(BUNDLE_STREAM):$(CSV_VERSION) \
--tag $(INDEX_STREAM):$(INDEX_VERSION)

.PHONY: test
test: undeploy scorecard
Expand All @@ -34,13 +79,9 @@ scorecard: generate
operator-sdk scorecard

.PHONY: clean
clean: clean-bundle
clean:
rm -rf build/_output

.PHONY: clean-bundle
clean-bundle:
rm -f bundle/*.crd.yaml




Expand All @@ -50,11 +91,11 @@ clean-bundle:

.PHONY: catalog
catalog: remove_catalog
oc create -f bundle/openshift/operator-source.yaml
oc create -f deploy/olm-catalog/catalog-source.yaml

.PHONY: remove_catalog
remove_catalog:
- oc delete -f bundle/openshift/operator-source.yaml
- oc delete -f deploy/olm-catalog/catalog-source.yaml

.PHONY: deploy
deploy: undeploy
Expand Down Expand Up @@ -82,7 +123,7 @@ undeploy: undeploy_sample_app undeploy_sample_app2
- oc delete serviceaccount container-jfr-operator
- oc delete crd flightrecorders.rhjmc.redhat.com
- oc delete crd containerjfrs.rhjmc.redhat.com
- oc delete -f bundle/openshift/operator-source.yaml
- oc delete -f deploy/olm-catalog/catalog-source.yaml

.PHONY: sample_app
sample_app:
Expand Down
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,38 @@ at the URL provided by

# Building
## Requirements
- `go`
- [operator-sdk](https://github.com/operator-framework/operator-sdk) v0.15.2
- `go` v1.13
- [`operator-sdk`](https://github.com/operator-framework/operator-sdk) v0.15.2
- [`opm`](https://github.com/operator-framework/operator-registry)
- `podman`

## Instructions
`make image` will create an OCI image to the local registry, tagged as
`quay.io/rh-jmc-team/container-jfr-operator`. This tag can be overridden by
setting the environment variable `IMAGE_TAG`.

To create a CSV bundle, use `CSV_VERSION=1.2.3 make csv`. This will generate
a CSV and CRDs for a bundle versioned 1.2.3 at
`./deploy/olm-catalog/container-jfr-operator-bundle/1.2.3`.

To (re)build the Operator bundle for packaging in catalogs (ex. OperatorHub),
use operator-courier, ex.
`operator-courier push bundle rh-jmc-team container-jfr-operator-bundle $VERSION $TOKEN`
, where `$VERSION` is the version string matching that within the bundle
definition YAMLs, and `$TOKEN` has been replaced by your personal quay.io
access token.
`CSV_VERSION=1.2.3 make bundle`. This will create an Operator bundle image
containing the required YAML manifest files and metadata for publishing the
bundle, based on the manifest files at
`./deploy/olm-catalog/container-jfr-operator-bundle/1.2.3`. Push the resulting
bundle image to an image registry such as quay.io.

To make this bundle available within the OpenShift Console's Operator Catalog,
add the custom Operator Source via `oc apply -f bundle/openshift/operator-source.yaml`
To create an index of these bundles, use `make index`. Push the index to an
image registry such as quay.io.

# Setup / Deployment

## UI-Guided Deployment

The operator can be deployed using the Operator Marketplace in the graphical
OpenShift console by first adding a custom operator source. A YAML definition
of such a custom source is at `bundle/openshift/operator-source.yaml`, which
OpenShift console by first adding a custom catalog source. A YAML definition
of such a custom source is at `deploy/olm-catalog/catalog-source.yaml`, which
can be added to your cluster by
`oc create -f bundle/openshift/operator-source.yaml` or simply `make catalog`.
`oc create -f deploy/olm-catalog/catalog-source.yaml` or simply `make catalog`.
This method allows the latest released version of the operator to be installed
into the cluster with the same method and in the same form that end users would
receive it.
Expand Down
4 changes: 0 additions & 4 deletions bundle/container-jfr-operator-bundle.package.yaml

This file was deleted.

Loading

0 comments on commit 25508e4

Please sign in to comment.