Skip to content

Commit 8cbc336

Browse files
authored
Merge branch 'master' into update_service_account
2 parents ad2a2b3 + 2cb3e2e commit 8cbc336

28 files changed

+517
-167
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: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ test/e2e-short:
9494
test/e2e/testrunner-k3d-%: PACKAGE=$*
9595
test/e2e/testrunner-k3d-%:
9696
bazel run //hack/k8s:k8s -- -type k3d
97-
bazel test --stamp //e2e/$(PACKAGE)/... --test_arg=-test.v --test_arg=-test.parallel=8 --test_arg=parallel=true
97+
bazel test --stamp //e2e/$(PACKAGE)/... --test_arg=-test.v --test_arg=-test.parallel=4 --test_arg=parallel=true
9898

9999
# Use this target to run e2e tests using a k3d k8s cluster.
100100
# This target uses k3d to start a k8s cluster and runs the e2e tests
@@ -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/manager/patches/image.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ spec:
186186
value: cockroachdb/cockroach:v22.1.14
187187
- name: RELATED_IMAGE_COCKROACH_v22_1_15
188188
value: cockroachdb/cockroach:v22.1.15
189+
- name: RELATED_IMAGE_COCKROACH_v22_1_16
190+
value: cockroachdb/cockroach:v22.1.16
191+
- name: RELATED_IMAGE_COCKROACH_v22_1_18
192+
value: cockroachdb/cockroach:v22.1.18
193+
- name: RELATED_IMAGE_COCKROACH_v22_1_20
194+
value: cockroachdb/cockroach:v22.1.20
189195
- name: RELATED_IMAGE_COCKROACH_v22_2_0
190196
value: cockroachdb/cockroach:v22.2.0
191197
- name: RELATED_IMAGE_COCKROACH_v22_2_1
@@ -198,3 +204,17 @@ spec:
198204
value: cockroachdb/cockroach:v22.2.4
199205
- name: RELATED_IMAGE_COCKROACH_v22_2_5
200206
value: cockroachdb/cockroach:v22.2.5
207+
- name: RELATED_IMAGE_COCKROACH_v22_2_6
208+
value: cockroachdb/cockroach:v22.2.6
209+
- name: RELATED_IMAGE_COCKROACH_v22_2_7
210+
value: cockroachdb/cockroach:v22.2.7
211+
- name: RELATED_IMAGE_COCKROACH_v22_2_8
212+
value: cockroachdb/cockroach:v22.2.8
213+
- name: RELATED_IMAGE_COCKROACH_v22_2_9
214+
value: cockroachdb/cockroach:v22.2.9
215+
- name: RELATED_IMAGE_COCKROACH_v23_1_0
216+
value: cockroachdb/cockroach:v23.1.0
217+
- name: RELATED_IMAGE_COCKROACH_v23_1_1
218+
value: cockroachdb/cockroach:v23.1.1
219+
- name: RELATED_IMAGE_COCKROACH_v23_1_2
220+
value: cockroachdb/cockroach:v23.1.2

0 commit comments

Comments
 (0)