Skip to content

Commit

Permalink
Cherry-pick CSV generation tooling into release-v1.10 (#855)
Browse files Browse the repository at this point in the history
* Add ClusterServiceVersion bundling (#682)

* Tag and push release images to RedHat Connect for validation (#688)

* Merge pull request #761 from lmm/lmm-fix-release-script

Exit release script gracefully if not on a tag

* Fix version in image tag (#818)

Co-authored-by: Erik Stidham <erik@tigera.io>
  • Loading branch information
lmm and tmjd committed Aug 25, 2020
1 parent 89dc44c commit e0cc1d3
Show file tree
Hide file tree
Showing 16 changed files with 767 additions and 314 deletions.
1 change: 1 addition & 0 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ blocks:
fi
secrets:
- name: quay-robot-semaphore_v2
- name: operator-redhat-connect
prologue:
commands:
- checkout
Expand Down
56 changes: 53 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ VALIDARCHES = $(filter-out $(EXCLUDEARCH),$(ARCHES))

PACKAGE_NAME?=github.com/tigera/operator
LOCAL_USER_ID?=$(shell id -u $$USER)
GO_BUILD_VER?=v0.40
GO_BUILD_VER?=v0.45
CALICO_BUILD?=calico/go-build:$(GO_BUILD_VER)
SRC_FILES=$(shell find ./pkg -name '*.go')
SRC_FILES+=$(shell find ./cmd -name '*.go')
Expand Down Expand Up @@ -420,13 +420,19 @@ endif
###############################################################################
# Utilities
###############################################################################
OPERATOR_SDK_VERSION=v0.18.1
hack/bin/operator-sdk-$(OPERATOR_SDK_VERSION):
OPERATOR_SDK_VERSION=v0.18.2
OPERATOR_SDK_BARE=hack/bin/operator-sdk
OPERATOR_SDK=$(OPERATOR_SDK_BARE)-$(OPERATOR_SDK_VERSION)
$(OPERATOR_SDK):
mkdir -p hack/bin
curl --fail -L -o hack/bin/operator-sdk-$(OPERATOR_SDK_VERSION) \
https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk-${OPERATOR_SDK_VERSION}-x86_64-linux-gnu
chmod +x hack/bin/operator-sdk-$(OPERATOR_SDK_VERSION)

.PHONY: $(OPERATOR_SDK_BARE)
$(OPERATOR_SDK_BARE): $(OPERATOR_SDK)
ln -f -s operator-sdk-$(OPERATOR_SDK_VERSION) $(OPERATOR_SDK_BARE)

## Generating code after API changes.
gen-files: hack/bin/operator-sdk-$(OPERATOR_SDK_VERSION)
cp hack/bin/operator-sdk-$(OPERATOR_SDK_VERSION) hack/bin/operator-sdk
Expand All @@ -445,6 +451,50 @@ $(BINDIR)/gen-versions: $(shell find ./hack/gen-versions -type f)
sh -c '$(GIT_CONFIG_SSH) \
go build -o $(BINDIR)/gen-versions ./hack/gen-versions'

## Generate a ClusterServiceVersion package.
# E.g. make gen-csv VERSION=1.6.2 PREV_VERSION=0.0.0
#
# VERSION: the operator version to generate a CSV for.
# PREV_VERSION: the operator version that this CSV will replace. If there is
# no previous version, use 0.0.0
.PHONY: gen-csv
gen-csv: $(OPERATOR_SDK_BARE) get-digest
$(eval EXTRA_DOCKER_ARGS += -e OPERATOR_IMAGE_INSPECT="$(OPERATOR_IMAGE_INSPECT)" -e VERSION=$(VERSION) -e PREV_VERSION=$(PREV_VERSION))
$(CONTAINERIZED) hack/gen-csv/csv.sh

.PHONY: prepull-image
prepull-image:
@echo Pulling operator image...
docker pull quay.io/tigera/operator:v$(VERSION)

# Get the digest for the image. This target runs docker commands on the host since the
# build container doesn't have docker-in-docker. 'docker inspect' returns output like the example
# below. RepoDigests may have more than one entry so we need to filter.
# [
# {
# "Id": "sha256:34a1114040c03830da0a8d57f8d999deba26d8e31bda353aed201a375f68870b",
# "RepoTags": [
# "quay.io/tigera/operator:v1.3.1",
# "..."
# ],
# "RepoDigests": [
# "quay.io/tigera/operator@sha256:5e1d551b5a711592472f4a3cc4645698d5f826da4253f0d47cfa5d5b641a2e1a",
# "..."
# ],
# ...
# }
# ]
.PHONY: get-digest
get-digest: prepull-image
@echo Getting operator image digest...
$(eval OPERATOR_IMAGE_INSPECT=$(shell sh -c "docker image inspect quay.io/tigera/operator:v$(VERSION) | base64 -w 0"))

## Generate a CSV bundle zip file containing all CSVs and a package manifest.
# E.g. make gen-bundle
.PHONY: gen-bundle
gen-bundle:
$(CONTAINERIZED) hack/gen-csv/bundle.sh

.PHONY: help
## Display this help text
help: # Some kind of magic from https://gist.github.com/rcmachado/af3db315e31383502660
Expand Down
37 changes: 37 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,40 @@ You should have no local changes and tests should be passing.
1. Close the milestone for this release. https://github.com/tigera/operator/milestones

1. Go to https://github.com/tigera/operator/milestones and create any new milestones that should exist (e.g., next patch release)

## Updates for new Calico CRDs

If the release includes new Calico CRDs, add the new CRDs to `hack/gen-csv/get-manifests.sh` and `hack/gen-csv/clusterserviceversion.template`.

## Publishing a release on RH Catalog

We currently only publish operator releases targeting Calico. If the release targets Calico, continue onto the following steps to generate the
ClusterServiceVersion for it, and publish the release on the RH Catalog.

1. After the semaphore job in the releasing steps is complete, and images have been tagged and pushed, checkout the tag you released.

1. Create the ClusterServiceVersion (CSV), using the tag version for VERSION and the version that this replaces in PREV_VERSION.
The versions are semver strings. For example:

```
make gen-csv VERSION=1.3.1 PREV_VERSION=1.3.0
```

This step will create the CSV and copy over its crds into `build/_output/bundle/tigera-operator/$VERSION` which will be used in the next step,
on master.

3. Checkout `master` and create a new branch.

4. Create the CSV bundle:

```
make gen-bundle
```

This step will add the CSV we generated earlier to `deploy/olm-catalog` and create a zip file in `build/_output/bundle/bundle.zip`.

5. `git add deploy/olm-catalog`, commit the changes, and have the PR reviewed and merged into master.

6. Login to our operator project metadata [submission page](https://connect.redhat.com/project/2072901/operator-metadata) and upload the bundle.zip

7. The metadata validation job takes 1-2 hours if it runs successfully. When it passes, go back to the same submission page and publish the new operator version.
4 changes: 0 additions & 4 deletions deploy/01-namespace.yaml

This file was deleted.

21 changes: 6 additions & 15 deletions deploy/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
# Deploy manifests for Kubernetes
# Deploy CRDs and scripts for tests

The manfiests in this directory can be used to install the operator on a Kubernetes cluster. They are
primarily intended for developers, are not guaranteed to be stable, and may be changed or broken at
any time without notice.
This directory contains:

## Using these manifests
- CRDs used in tests
- Scripts to provision test clusters
- And the latest set of package manifests in `olm-catalog`

1. First install the operator's CRD:
For release versions of CRDs and operator manifests (deployment, RBAC, etc.), see the Calico [Kubernetes](https://docs.projectcalico.org/getting-started/kubernetes/quickstart) or [OpenShift](https://docs.projectcalico.org/getting-started/openshift/installation) installation instructions.

kubectl apply -f crds/operator-crd.yaml

1. The operator manifests are found in this directory.

kubectl apply -f .

1. Install the configuration CRD.

kubectl apply -f crds/default.yaml
37 changes: 0 additions & 37 deletions deploy/operator.yaml

This file was deleted.

0 comments on commit e0cc1d3

Please sign in to comment.