Skip to content
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

Update operator-sdk version #74

Merged
merged 13 commits into from
Feb 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ tags
.history
# End of https://www.gitignore.io/api/go,vim,emacs,visualstudiocode

bundle/*.crd.yaml
vendor/
9 changes: 5 additions & 4 deletions .osdk-scorecard.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
---
# TODO automatically update bundle/CSV version number
scorecard:
output: text
namespace: scorecard
crds-dir: "deploy/crds"
bundle: "deploy/olm-catalog/container-jfr-operator-bundle"
plugins:
# TODO add test configurations for FlightRecorders
- basic:
crds-dir: "deploy/crds"
cr-manifest:
- "deploy/crds/rhjmc.redhat.com_v1alpha1_containerjfr_cr.yaml"
- "deploy/crds/rhjmc.redhat.com_v1alpha1_flightrecorder_cr.yaml"
- olm:
crds-dir: "deploy/crds"
cr-manifest:
- "deploy/crds/rhjmc.redhat.com_v1alpha1_containerjfr_cr.yaml"
- "deploy/crds/rhjmc.redhat.com_v1alpha1_flightrecorder_cr.yaml"
csv-path: "bundle/container-jfr-operator.v0.3.0.clusterserviceversion.yaml"
csv-path: "deploy/olm-catalog/container-jfr-operator-bundle/0.3.0/container-jfr-operator-bundle.v0.3.0.clusterserviceversion.yaml"
97 changes: 75 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,46 +1,99 @@
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.0
IMAGE_TAG ?= $(IMAGE_STREAM):$(IMAGE_VERSION)

BUNDLE_STREAM ?= $(IMAGE_STREAM)-bundle
CSV_VERSION ?= $(IMAGE_VERSION)
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

.PHONY: generate
generate: k8s openapi
generate: k8s crds

.PHONY: k8s
k8s:
operator-sdk generate k8s

.PHONY: openapi
openapi:
operator-sdk generate openapi
.PHONY: crds
crds:
operator-sdk generate crds

.PHONY: csv
csv: generate
ifeq ($(CSV_VERSION), $(PREV_CSV_VERSION))
operator-sdk generate csv \
--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
else
# 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
endif

.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:
operator-sdk bundle validate \
--image-builder $(BUILDER) \
$(IMAGE_TAG)

.PHONY: index
index:
ifeq ($(INDEX_VERSION), $(PREV_INDEX_VERSION))
opm index add \
--bundles $(BUNDLE_STREAM):$(CSV_VERSION) \
--tag $(INDEX_STREAM):$(INDEX_VERSION)
else
# 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)
endif

.PHONY: test
test: undeploy scorecard

.PHONY: scorecard
scorecard: generate
scorecard:
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 +103,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 +135,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
31 changes: 17 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,38 @@ at the URL provided by

# Building
## Requirements
- `go`
- [operator-sdk](https://github.com/operator-framework/operator-sdk) v0.11.0
- [operator-courier](https://github.com/operator-framework/operator-courier) 2.1.7+
- `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