Skip to content

Commit

Permalink
Updated release process for the bundles (k8ssandra#288)
Browse files Browse the repository at this point in the history
* Updated release process for the bundles

* Enable git checkout for commit

* Fix target-directory for certified-operators

* Uncomment git tag checkout and add small note to certified-operators release process to remind that the user must have access in the RH portal
  • Loading branch information
burmanm authored Mar 8, 2022
1 parent 31b0230 commit 77eecf9
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ M_INTEG_DIR ?= all
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)

# Image URL to use all building/pushing image targets
IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
IMG ?= $(IMAGE_TAG_BASE):v$(VERSION)
IMG_LATEST ?= $(IMAGE_TAG_BASE):latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true"
Expand All @@ -60,7 +60,7 @@ ENVTEST_K8S_VERSION = 1.22

# Logger image
LOG_IMG_BASE ?= $(ORG)/system-logger
LOG_IMG ?= $(LOG_IMG_BASE):$(VERSION)
LOG_IMG ?= $(LOG_IMG_BASE):v$(VERSION)
LOG_IMG_LATEST ?= $(LOG_IMG_BASE):latest

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
Expand Down
51 changes: 30 additions & 21 deletions docs/developer/release-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,41 @@ The github action will create docker images and bundles.

# How to release OperatorHub bundle

Follow the process in: https://operatorhub.io/contribute
OperatorHub has been split to two different community parts, one appearing for Kubernetes OLM installations and one for Openshift's integrated OperatorHub instance. We need to publish to both.
It happens by creating a PR to two different repositories:

The output of ``make bundle bundle-build`` should be valid if the development process was correct. Create the bundle which will be submitted in the PR with a correct version, for example for v1.10.0:
https://github.com/redhat-openshift-ecosystem/community-operators-prod
https://github.com/k8s-operatorhub/community-operators

``make IMG=k8ssandra/cass-operator:v1.10.0 bundle bundle-build``
A script has been created which will create the necessary packages, branch and a commit. The prerequisite is that those two must be checked out to same level directory as cass-operator so that they
can be accessed with ``../community-operators/`` and ``../community-operators-prod``. Only users in the ``cass-operator-community/ci.yaml`` in those repository can submit updates. The commits
must be signed, thus ensure your git properties are correctly set.

Add the bundle directory as the input for the PR one submits for operatorhub.io
The script is run by first checking out the correct tag in the ``cass-operator`` repository and then running:

``scripts/release-community-olm.sh version``

where ``version`` is without ``v``-prefix, for example ``1.11.0``. You need to manually push the created branch ``cass-operator-$VERSION`` and make a PR, the script will not do that part.

# How to release Red Hat certified bundles

* Upload images to the Red Hat using the connect.redhat.com
* If the images are built using ubi8-micro, you need to make a support ticket to ask them for a waiver since their validation process is broken
* Include oisp, project_id, sha256 of the image etc.
* Proceed only after you've received OK from them
* Create bundle with the new SHA256 image: (make VERSION=1.9.0 IMG=registry.connect.redhat.com/datastax/cass-operator@sha256:f14b6b217ecf4f6b3dc1b43210ed51d6be56d70e5bbc5444861df73934631d3c bundle)
* Modify bundle's imageConfig to use the SHA256 image of system-logger
* Verify CSV's metadata.name to be cass-operator.v<version>
* Ensure yamllint passes
* Line changes are not validated by RH, and also some indentation mistakes are fine (array indentation starts from same pos is fine)
* Verify version is set correctly (and not v1.9.0-dev.ac96a72-20220209 etc)
* Add spec/relatedImages to CSV
* Upload images to the Red Hat using the connect.redhat.com portal
* Select container images and "push manually" for instructions. Upload cass-operator and system-logger if you wish to update that one also (if there are no changes, then no need to)
* If the images are built using ubi8-micro, you need to make a support ticket to ask them for a waiver since their validation process is broken. This happens after the upload is done and the
only failure is rpm_list
* Include oisp, project_id, sha256 of the image to the ticket
* Proceed only after you've received OK from them (the state on the portal changes to "Passed")
* Publish the container image from the portal
* If the system-logger image was updated, modify ``scripts/release-certified-bundles.sh`` with the new SHA256

Checkout certified-operators (and if required, certified-operators-marketplace) to a directory at the same level as cass-operator.

Copy the SHA256 of the published image and run the following script:

``scripts/release-certified-bundles.sh version sha256:<sha256>``, version without ``v`` prefix and sha256 with the ``sha256:`` prefix (the copy button on the portal puts it automatically). For example:

```
spec:
relatedImages:
- name: cass-operator
image: registry.connect.redhat.com/datastax/cass-operator@sha256:f14b6b217ecf4f6b3dc1b43210ed51d6be56d70e5bbc5444861df73934631d3c
- name: system-logger
image: registry.connect.redhat.com/datastax/system-logger@sha256:33e75d0c78a277cdc37be24f2b116cade0d9b7dc7249610cdf9bf0705c8a040e
scripts/release-certified-bundles.sh 1.10.1 sha256:ae709b680dde2aa43c92d6b331af0554c9af92aa9fad673454892ca2b40bd3f7
```

When sending the PR, the PR must have title structured: ``operator cass-operator (v$VERSION)``, such as ``operator cass-operator (v1.10.1)``. Also, the user must be added to the accepted user list from the Red Hat's portal (project settings).
4 changes: 2 additions & 2 deletions scripts/postprocess-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# These labels are required to be in the bundle.Dockerfile, but can't be added by the operator-sdk automatically
cat <<EOF >> bundle.Dockerfile
# Certified Openshift required labels
LABEL com.redhat.openshift.versions="v4.8"
LABEL com.redhat.openshift.versions="v4.7"
LABEL com.redhat.delivery.operator.bundle=true
LABEL com.redhat.delivery.backport=true
EOF

# Add them to the bundle metadata also
yq eval -i '.annotations."com.redhat.openshift.versions" = "v4.8"' bundle/metadata/annotations.yaml
yq eval -i '.annotations."com.redhat.openshift.versions" = "v4.7"' bundle/metadata/annotations.yaml
yq eval -i '.annotations."com.redhat.delivery.operator.bundle" = true' bundle/metadata/annotations.yaml
yq eval -i '.annotations."com.redhat.delivery.backport" = true' bundle/metadata/annotations.yaml
yq eval -i '.annotations."com.redhat.openshift.versions" headComment = "Certified Openshift required labels"' bundle/metadata/annotations.yaml
Expand Down
43 changes: 43 additions & 0 deletions scripts/release-certified-bundles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh

if [ "$#" -ne 2 ]; then
echo "Usage: scripts/release-certified-bundles.sh version sha256:<sha256>"
echo "Script assumes you are in the correct branch / tag and that community-operators repository"
echo "has been checked out to ../community-operators/"
exit
fi

VERSION=$1
SHA=$2
# TODO Add certified-operators-marketplace
TARGET_DIRS=(certified-operators)
SYSTEM_LOGGER_SHA=sha256:33e75d0c78a277cdc37be24f2b116cade0d9b7dc7249610cdf9bf0705c8a040e

# Checkout tag
git checkout v$VERSION

yq -i '.images.system-logger = "registry.connect.redhat.com/datastax/system-logger@"' config/manager/image_config.yaml
SYSTEM_LOGGER_SHA=$SYSTEM_LOGGER_SHA yq -i '.images.system-logger += env(SYSTEM_LOGGER_SHA)' config/manager/image_config.yaml

# Create bundle
make VERSION=$VERSION IMG=registry.connect.redhat.com/datastax/cass-operator@$SHA bundle

# Add relatedImages
yq -i '.spec.relatedImages = []' bundle/manifests/cass-operator.clusterserviceversion.yaml
yq -i '.spec.relatedImages += {"name": "cass-operator", "image": "registry.connect.redhat.com/datastax/cass-operator@"}' bundle/manifests/cass-operator.clusterserviceversion.yaml
yq -i '.spec.relatedImages += {"name": "system-logger", "image": "registry.connect.redhat.com/datastax/system-logger@"}' bundle/manifests/cass-operator.clusterserviceversion.yaml
SHA=$SHA yq -i '.spec.relatedImages[0].image += env(SHA)' bundle/manifests/cass-operator.clusterserviceversion.yaml
SYSTEM_LOGGER_SHA=$SYSTEM_LOGGER_SHA yq -i '.spec.relatedImages[1].image += env(SYSTEM_LOGGER_SHA)' bundle/manifests/cass-operator.clusterserviceversion.yaml

for dir in "${TARGET_DIRS[@]}"
do
TARGET_DIR=../$dir/operators/cass-operator/v$VERSION
mkdir $TARGET_DIR
cp -R bundle/* $TARGET_DIR

cd $TARGET_DIR
git checkout -b cass-operator-$VERSION main
git add .
git commit -s -am "operator cass-operator (v${VERSION})"
cd -
done
33 changes: 33 additions & 0 deletions scripts/release-community-bundles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh

if [ "$#" -ne 1 ]; then
echo "Usage: scripts/release-community-bundles.sh version"
echo "Script assumes you are in the correct branch / tag and that community-operators repository"
echo "has been checked out to ../community-operators/"
exit
fi

VERSION=$1
TARGET_DIRS=(community-operators community-operators-prod)

# Checkout tag
git checkout v$VERSION

# Create bundle
make VERSION=$VERSION bundle

# Modify package name to cass-operator-community
yq eval -i '.annotations."operators.operatorframework.io.bundle.package.v1" = "cass-operator-community"' bundle/metadata/annotations.yaml

for dir in "${TARGET_DIRS[@]}"
do
TARGET_DIR=../$dir/operators/cass-operator-community/$VERSION
mkdir $TARGET_DIR
cp -R bundle/* $TARGET_DIR

cd $TARGET_DIR
git checkout -b cass-operator-$VERSION main
git add .
git commit -s -am "cass-operator-community v${VERSION}"
cd -
done

0 comments on commit 77eecf9

Please sign in to comment.