Skip to content

Commit 2cb3e2e

Browse files
Update Openshift Release Process (#964)
* Install preflight binary on Linux machines Adding preflight to the list of OpenShift binaries installed. For now, this is only available on Linux machines and won't be added to anyone using Darwin. * Publish operator and bundle images for RedHat/OpenShift Updating the build/release scripts to handle publishing the bundle images and running preflight on them. The publish-openshift script downloads the tagged release from DockerHub, retags it correctly for the RedHat scanning repo, pushes it, and finally runs the preflight check on it. The openshift-bundle script largely does the same, only it publishes the bundle image rather than the operator image. The same script is used for both the certified and marketplace bundles. Passing `MARKETPLACE=1` will use the marketplace bundle values rather than the certified ones (default). * Update OpenShift binaries to 4.10.18 Updated all of the outdated OpenShift binaries. This also includes a fix to an issue with had with opm. We were copying the tar file into the bin folder and marking it as executable. This naturally, caused issues when we tried to run it. * Add support for make test/preflight-<target> Adding targets for running preflight tests. These only work on Linux machines since preflight is currently not available on other platforms. The preflight tasks all assume you've got a running OpenShift cluster and that GCP_PROJECT and KUBECONFIG are set accordingly in the env. * Build, Publish and automate release process for openshift * Fix the review comments --------- Co-authored-by: David Muto (pseudomuto) <[email protected]>
1 parent 92b1090 commit 2cb3e2e

15 files changed

+371
-138
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@ bundle/
6363
faq
6464

6565
_artifacts
66-
bundle.Dockerfile
66+
artifacts
6767
tmp

Makefile

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ test/e2e/testrunner-openshift-packaging: test/openshift-package
210210
--action_env=APP_VERSION=$(APP_VERSION) \
211211
--action_env=DOCKER_REGISTRY=$(DOCKER_REGISTRY)
212212

213+
# Run preflight checks for OpenShift. This expects a running OpenShift cluster.
214+
# Eg. make test/preflight-<operator|bundle|marketplace>
215+
test/preflight-%: CONTAINER=$*
216+
test/preflight-%: release/generate-bundle
217+
@bazel run //hack:redhat-preflight -- $(CONTAINER)
218+
213219
#
214220
# Different dev targets
215221
#
@@ -267,6 +273,7 @@ dev/up: dev/down
267273

268274
.PHONY: dev/down
269275
dev/down:
276+
@bazel build //hack/bin:k3d
270277
@hack/dev.sh down
271278
#
272279
# Targets that allow to install the operator on an existing cluster
@@ -332,7 +339,7 @@ release/image:
332339
# RedHat OpenShift targets
333340
#
334341

335-
#RED HAT IMAGE BUNDLE
342+
#REDHAT IMAGE BUNDLE
336343
RH_BUNDLE_REGISTRY?=registry.connect.redhat.com/cockroachdb
337344
RH_BUNDLE_IMAGE_REPOSITORY?=cockroachdb-operator-bundle
338345
RH_BUNDLE_VERSION?=$(VERSION)
@@ -356,3 +363,16 @@ PKG_MAN_OPTS ?= "$(PKG_CHANNELS) $(PKG_DEFAULT_CHANNEL)"
356363
.PHONY: release/generate-bundle
357364
release/generate-bundle:
358365
bazel run //hack:bundle -- $(RH_BUNDLE_VERSION) $(RH_OPERATOR_IMAGE) $(PKG_MAN_OPTS) $(RH_COCKROACH_DATABASE_IMAGE)
366+
367+
.PHONY: release/publish-operator
368+
publish-operator:
369+
./build/release/teamcity-publish-release.sh
370+
371+
.PHONY: release/publish-operator-openshift
372+
publish-operator-openshift:
373+
./build/release/teamcity-publish-openshift.sh
374+
375+
.PHONY: release/publish-openshift-bundle
376+
release/publish-openshift-bundle:
377+
./build/release/teamcity-publish-openshift-bundle.sh
378+

build/release/teamcity-publish-openshift-bundle.sh

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,54 @@ set -euxo pipefail
1717

1818
source "$(dirname "${0}")/teamcity-support.sh"
1919

20+
# Default values are defined for the certified bundle.
21+
RH_PROJECT="5f5a433f9d6546ed7aa8634d"
22+
RH_REGISTRY="scan.connect.redhat.com"
23+
RH_REPO="ospid-857fe786-3eb7-4508-aafd-cc74c1b1dc24/cockroachdb-operator-bundle"
24+
BUNDLE_DIR="bundle/cockroachdb-certified"
2025

21-
tc_start_block "Variable Setup"
22-
VERSION="v"$(cat version.txt)
23-
# Matching the version name regex from within the cockroach code except
24-
# for the `metadata` part at the end because Docker tags don't support
25-
# `+` in the tag name.
26-
# https://github.com/cockroachdb/cockroach/blob/4c6864b44b9044874488cfedee3a31e6b23a6790/pkg/util/version/version.go#L75
27-
image_tag="$(echo "${VERSION}" | grep -E -o '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[-.0-9A-Za-z]+)?$')"
28-
# ^major ^minor ^patch ^preRelease
29-
30-
if [[ -z "$image_tag" ]] ; then
31-
echo "Invalid VERSION \"${VERSION}\". Must be of the format \"vMAJOR.MINOR.PATCH(-PRERELEASE)?\"."
32-
exit 1
26+
# If this is the marketplace bundle, update accordingly.
27+
if ! [[ -z "${MARKETPLACE}" ]]; then
28+
RH_PROJECT="61765afbdd607bfc82e643b8"
29+
RH_REPO="ospid-61765afbdd607bfc82e643b8/cockroachdb-operator-bundle-marketplace"
30+
BUNDLE_DIR="bundle/cockroachdb-certified-rhmp"
3331
fi
3432

35-
rhel_registry="scan.connect.redhat.com"
36-
rh_bundle_image_repository="ospid-857fe786-3eb7-4508-aafd-cc74c1b1dc24/cockroachdb-operator-bundle"
37-
image="$rhel_registry/$rh_bundle_image_repository:$image_tag"
33+
# If it's a dry run, add -dryrun to the image
34+
if ! [[ -z "${DRY_RUN}" ]]; then RH_REPO="${RH_REPO}-dryrun"; fi
3835

39-
if ! [[ -z "${DRY_RUN}" ]] ; then
40-
image="${image}-dryrun"
41-
fi
42-
tc_end_block "Variable Setup"
36+
IMAGE="${RH_REGISTRY}/${RH_REPO}:${TAG}"
37+
38+
main() {
39+
docker_login "${RH_REGISTRY}" "${OPERATOR_REDHAT_REGISTRY_USER}" "${OPERATOR_REDHAT_REGISTRY_KEY}"
40+
41+
generate_bundle
42+
publish_bundle_image
43+
run_preflight
44+
}
45+
46+
generate_bundle() {
47+
# create the certified and marketplace bundles
48+
tc_start_block "Generate bundle"
49+
make release/generate-bundle
50+
tc_end_block "Generate bundle"
51+
}
52+
53+
publish_bundle_image() {
54+
tc_start_block "Make and push bundle image"
4355

56+
pushd "${BUNDLE_DIR}"
57+
docker build -t "${IMAGE}" .
58+
docker push "${IMAGE}"
59+
popd
4460

45-
tc_start_block "Make and push docker images"
46-
configure_docker_creds
47-
docker_login "$rhel_registry" "$OPERATOR_BUNDLE_REDHAT_REGISTRY_USER" "$OPERATOR_BUNDLE_REDHAT_REGISTRY_KEY"
61+
tc_end_block "Make and push bundle image"
62+
}
4863

49-
# TODO(rail): switch to bazel generated images when it supports "FROM: scratch"
50-
cd deploy/certified-metadata-bundle/cockroach-operator
51-
docker build -t $image -f bundle.Dockerfile .
52-
docker push $image
64+
run_preflight() {
65+
bazel build //hack/bin:preflight
66+
PFLT_PYXIS_API_TOKEN="${REDHAT_API_TOKEN}" bazel-bin/hack/bin/preflight \
67+
check operator "${IMAGE}" --docker-config ~/.docker/config.json
68+
}
5369

54-
tc_end_block "Make and push docker images"
70+
main "$@"

build/release/teamcity-publish-openshift.sh

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,37 @@ set -euxo pipefail
1717

1818
source "$(dirname "${0}")/teamcity-support.sh"
1919

20+
RH_PROJECT_ID="5e6027425c5456060d5f6084"
21+
RH_REGISTRY="scan.connect.redhat.com"
22+
RH_OPERATOR_IMG="${RH_REGISTRY}/ospid-cf721588-ad8a-4618-938c-5191c5e10ae4/cockroachdb-operator:${TAG}"
2023

21-
tc_start_block "Variable Setup"
22-
VERSION="v"$(cat version.txt)
23-
# Matching the version name regex from within the cockroach code except
24-
# for the `metadata` part at the end because Docker tags don't support
25-
# `+` in the tag name.
26-
# https://github.com/cockroachdb/cockroach/blob/4c6864b44b9044874488cfedee3a31e6b23a6790/pkg/util/version/version.go#L75
27-
image_tag="$(echo "${VERSION}" | grep -E -o '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[-.0-9A-Za-z]+)?$')"
28-
# ^major ^minor ^patch ^preRelease
29-
30-
if [[ -z "$image_tag" ]] ; then
31-
echo "Invalid VERSION \"${VERSION}\". Must be of the format \"vMAJOR.MINOR.PATCH(-PRERELEASE)?\"."
32-
exit 1
33-
fi
34-
35-
rhel_registry="scan.connect.redhat.com"
36-
37-
dh_operator_image="docker.io/cockroachdb/cockroach-operator:$image_tag"
38-
rh_operator_image_repository="$rhel_registry/ospid-cf721588-ad8a-4618-938c-5191c5e10ae4/cockroachdb-operator"
39-
24+
OPERATOR_IMG="docker.io/cockroachdb/cockroach-operator:${TAG}"
4025
if ! [[ -z "${DRY_RUN}" ]] ; then
41-
# The operator image doesn't use the "-dryrun" suffix, it's published in a
42-
# separate repository.
43-
dh_operator_image="docker.io/cockroachdb/cockroach-operator-misc:$image_tag"
44-
image_tag="${image_tag}-dryrun"
26+
OPERATOR_IMG="docker.io/cockroachdb/cockroach-operator-misc:${TAG}-dryrun"
4527
fi
46-
tc_end_block "Variable Setup"
47-
48-
49-
tc_start_block "Make and push docker images"
50-
configure_docker_creds
51-
docker_login "$rhel_registry" "$OPERATOR_REDHAT_REGISTRY_USER" "$OPERATOR_REDHAT_REGISTRY_KEY"
52-
53-
docker pull "$dh_operator_image"
54-
docker tag "$dh_operator_image" "$rh_operator_image_repository:$image_tag"
55-
docker push "$rh_operator_image_repository:$image_tag"
5628

57-
tc_end_block "Make and push docker images"
29+
main() {
30+
docker_login "${RH_REGISTRY}" "${OPERATOR_REDHAT_REGISTRY_USER}" "${OPERATOR_REDHAT_REGISTRY_KEY}"
31+
32+
publish_to_redhat
33+
run_preflight
34+
}
35+
36+
publish_to_redhat() {
37+
tc_start_block "Tag and release docker image"
38+
docker pull "${OPERATOR_IMG}"
39+
docker tag "${OPERATOR_IMG}" "${RH_OPERATOR_IMG}"
40+
docker push "${RH_OPERATOR_IMG}"
41+
tc_end_block "Tag and release docker image"
42+
}
43+
44+
run_preflight() {
45+
bazel build //hack/bin:preflight
46+
PFLT_PYXIS_API_TOKEN="${REDHAT_API_TOKEN}" bazel-bin/hack/bin/preflight \
47+
check container "${RH_OPERATOR_IMG}" \
48+
--certification-project-id="${RH_PROJECT_ID}" \
49+
--docker-config=/home/agent/.docker/config.json \
50+
--submit
51+
}
52+
53+
main "$@"

build/release/teamcity-publish-release.sh

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -17,45 +17,45 @@ set -euxo pipefail
1717

1818
source "$(dirname "${0}")/teamcity-support.sh"
1919

20-
tc_start_block "Variable Setup"
21-
VERSION="v"$(cat version.txt)
22-
# Matching the version name regex from within the cockroach code except
23-
# for the `metadata` part at the end because Docker tags don't support
24-
# `+` in the tag name.
25-
# https://github.com/cockroachdb/cockroach/blob/4c6864b44b9044874488cfedee3a31e6b23a6790/pkg/util/version/version.go#L75
26-
image_tag="$(echo "${VERSION}" | grep -E -o '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[-.0-9A-Za-z]+)?$')"
27-
# ^major ^minor ^patch ^preRelease
28-
29-
if [[ -z "$image_tag" ]] ; then
30-
echo "Invalid VERSION \"${VERSION}\". Must be of the format \"vMAJOR.MINOR.PATCH(-PRERELEASE)?\"."
31-
exit 1
32-
fi
33-
34-
docker_registry="docker.io"
35-
operator_image_repository="cockroachdb/cockroach-operator"
36-
37-
if ! [[ -z "${DRY_RUN}" ]] ; then
38-
operator_image_repository="cockroachdb/cockroach-operator-misc"
39-
fi
40-
41-
tc_end_block "Variable Setup"
42-
43-
tc_start_block "Make and push docker images"
44-
configure_docker_creds
45-
docker_login "$docker_registry" "$OPERATOR_DOCKER_ID" "$OPERATOR_DOCKER_ACCESS_TOKEN"
46-
47-
if docker_image_exists "$docker_registry/$operator_image_repository:$image_tag"; then
48-
echo "Docker image $docker_registry/$operator_image_repository:$image_tag already exists"
49-
if [[ -z "${FORCE}" ]] ; then
50-
echo "Use FORCE=1 to force push the docker image."
51-
echo "Alternatively you can delete the tag in Docker Hub."
52-
exit 1
20+
REGISTRY="docker.io"
21+
REPO="cockroachdb/cockroach-operator"
22+
if ! [[ -z "${DRY_RUN}" ]] ; then REPO="${REPO}-misc"; fi
23+
24+
OPERATOR_IMG="${REGISTRY}/${REPO}:${TAG}"
25+
26+
main() {
27+
docker_login "${REGISTRY}" "${OPERATOR_DOCKER_ID}" "${OPERATOR_DOCKER_ACCESS_TOKEN}"
28+
29+
validate_image
30+
publish_to_registry
31+
}
32+
33+
validate_image() {
34+
tc_start_block "Ensure image should be pushed"
35+
36+
if docker_image_exists "${OPERATOR_IMG}"; then
37+
echo "Docker image ${OPERATOR_IMG} already exists!"
38+
39+
if [[ -z "${FORCE}" ]] ; then
40+
echo "Use FORCE=1 to force push the docker image."
41+
echo "Alternatively you can delete the tag in Docker Hub."
42+
exit 1
43+
fi
44+
echo "Forcing docker push..."
5345
fi
54-
echo "Forcing docker push..."
55-
fi
56-
57-
make \
58-
DOCKER_REGISTRY="$docker_registry" \
59-
DOCKER_IMAGE_REPOSITORY="$operator_image_repository" \
60-
release/image
61-
tc_end_block "Make and push docker images"
46+
47+
tc_end_block "Ensure image should be pushed"
48+
}
49+
50+
publish_to_registry() {
51+
tc_start_block "Make and push docker image"
52+
53+
make \
54+
DOCKER_REGISTRY="${REGISTRY}" \
55+
DOCKER_IMAGE_REPOSITORY="${REPO}" \
56+
release/image
57+
58+
tc_end_block "Make and push docker image"
59+
}
60+
61+
main "$@"

build/release/teamcity-support.sh

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# Set below with call to ensure_valid_tag
16+
export TAG=""
17+
1518
# Common helpers for teamcity-*.sh scripts.
1619

1720
remove_files_on_exit() {
@@ -29,10 +32,12 @@ tc_end_block() {
2932
}
3033

3134
docker_login() {
32-
local registry=$1
33-
local registry_user=$2
34-
local registry_token=$3
35-
echo "${registry_token}" | docker login --username "${registry_user}" --password-stdin $registry
35+
configure_docker_creds
36+
37+
local registry="${1}"
38+
local registry_user="${2}"
39+
local registry_token="${3}"
40+
echo "${registry_token}" | docker login --username "${registry_user}" --password-stdin "${registry}"
3641
}
3742

3843
configure_docker_creds() {
@@ -55,3 +60,24 @@ docker_image_exists() {
5560
docker pull "$1"
5661
return $?
5762
}
63+
64+
ensure_valid_tag() {
65+
tc_start_block "Extracting image tag"
66+
local version="v$(cat version.txt)"
67+
68+
# Matching the version name regex from within the cockroach code except
69+
# for the `metadata` part at the end because Docker tags don't support
70+
# `+` in the tag name.
71+
# https://github.com/cockroachdb/cockroach/blob/4c6864b44b9044874488cfedee3a31e6b23a6790/pkg/util/version/version.go#L75
72+
TAG="$(echo -n "${version}" | grep -E -o '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[-.0-9A-Za-z]+)?$')"
73+
# ^major ^minor ^patch ^preRelease
74+
75+
if [[ -z "${TAG}" ]] ; then
76+
echo "Invalid VERSION \"${version}\". Must be of the format \"vMAJOR.MINOR.PATCH(-PRERELEASE)?\"."
77+
exit 1
78+
fi
79+
80+
tc_end_block "Extracting image tag"
81+
}
82+
83+
ensure_valid_tag

config/default/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ k8s_deploy(
3434
# when running locally, use the image from the local codebase
3535
"cockroachdb/cockroach-operator:$(APP_VERSION)": "//cmd/cockroach-operator:operator_image",
3636
},
37+
resolver_args = ["--allow_unused_images"],
3738
template = ":manifest",
3839
)
3940

config/manifests/bases/cockroach-operator.clusterserviceversion.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ spec:
178178
179179
name: Cockroach Labs Support
180180
maturity: stable
181+
minKubeVersion: 1.18.0
181182
provider:
182183
name: Cockroach Labs
183184
version: 0.0.0

config/manifests/kustomization.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ namespace: placeholder
1717
resources:
1818
- ../default
1919
- ../samples
20+
- ../scorecard
21+
2022

2123
patchesStrategicMerge:
2224
- patches/deployment_patch.yaml

config/templates/csv.yaml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ spec:
178178
179179
name: Cockroach Labs Support
180180
maturity: stable
181+
minKubeVersion: 1.18.0
181182
provider:
182183
name: Cockroach Labs
183184
version: 0.0.0

0 commit comments

Comments
 (0)