Skip to content

Commit 083f319

Browse files
authored
Run on-cluster-builds in separate namespace to OLM (#3798)
1 parent d0ca313 commit 083f319

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

hack/images.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ echo "On cluster builds: ${on_cluster_builds}"
2626
echo "Target platform: ${TARGET_OS}/${TARGET_ARCH}"
2727

2828
if [[ $on_cluster_builds = true ]]; then
29-
# image-registry.openshift-image-registry.svc:5000/openshift-marketplace/openshift-knative-operator:latest
29+
# image-registry.openshift-image-registry.svc:5000/openshift-serverless-builds/openshift-knative-operator:latest
3030
build_image "serverless-openshift-knative-operator" "${root_dir}" "openshift-knative-operator/Dockerfile" || exit 1
31-
# image-registry.openshift-image-registry.svc:5000/openshift-marketplace/knative-operator:latest
31+
# image-registry.openshift-image-registry.svc:5000/openshift-serverless-builds/knative-operator:latest
3232
build_image "serverless-knative-operator" "${root_dir}" "knative-operator/Dockerfile" || exit 1
33-
# image-registry.openshift-image-registry.svc:5000/openshift-marketplace/knative-openshift-ingress:latest
33+
# image-registry.openshift-image-registry.svc:5000/openshift-serverless-builds/knative-openshift-ingress:latest
3434
build_image "serverless-ingress" "${root_dir}" "serving/ingress/Dockerfile" || exit 1
3535

3636
logger.info 'Image builds finished'

hack/lib/catalogsource.bash

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ function install_catalogsource {
2626
# Build bundle and index images only when running in CI or when DOCKER_REPO_OVERRIDE is defined,
2727
# unless overridden by FORCE_KONFLUX_INDEX.
2828
if { [ -n "$OPENSHIFT_CI" ] || [ -n "$DOCKER_REPO_OVERRIDE" ]; } && [ -z "${FORCE_KONFLUX_INDEX:-}" ]; then
29-
index_image=image-registry.openshift-image-registry.svc:5000/$OLM_NAMESPACE/serverless-index:latest
30-
bundle_image=image-registry.openshift-image-registry.svc:5000/$OLM_NAMESPACE/serverless-bundle:latest
29+
index_image=image-registry.openshift-image-registry.svc:5000/$ON_CLUSTER_BUILDS_NAMESPACE/serverless-index:latest
30+
bundle_image=image-registry.openshift-image-registry.svc:5000/$ON_CLUSTER_BUILDS_NAMESPACE/serverless-bundle:latest
3131
rootdir="$(dirname "$(dirname "$(dirname "$(realpath "${BASH_SOURCE[0]}")")")")"
3232

3333
csv="${rootdir}/olm-catalog/serverless-operator/manifests/serverless-operator.clusterserviceversion.yaml"
@@ -58,12 +58,15 @@ function install_catalogsource {
5858
# TODO: Use proper secrets for OPM instead of unauthenticated user,
5959
# See https://github.com/operator-framework/operator-registry/issues/919
6060

61-
# Allow OPM to pull the serverless-bundle from openshift-marketplace ns from internal registry.
62-
oc adm policy add-role-to-group system:image-puller system:unauthenticated --namespace openshift-marketplace
61+
# Allow OPM to pull the serverless-bundle from openshift-serverless-builds ns from internal registry.
62+
oc adm policy add-role-to-group system:image-puller system:unauthenticated --namespace "${OLM_NAMESPACE}"
63+
oc adm policy add-role-to-group system:image-puller system:unauthenticated --namespace "${ON_CLUSTER_BUILDS_NAMESPACE}"
6364

6465
# export ON_CLUSTER_BUILDS=true; make images
65-
# will push images to ${OLM_NAMESPACE} namespace, allow the ${OPERATORS_NAMESPACE} namespace to pull those images.
66-
oc adm policy add-role-to-group system:image-puller system:serviceaccounts:"${OPERATORS_NAMESPACE}" --namespace "${OLM_NAMESPACE}"
66+
# will push images to ${ON_CLUSTER_BUILDS_NAMESPACE} namespace, allow the ${OPERATORS_NAMESPACE} namespace to pull those images.
67+
oc adm policy add-role-to-group system:image-puller system:serviceaccounts:"${ON_CLUSTER_BUILDS_NAMESPACE}" --namespace "${ON_CLUSTER_BUILDS_NAMESPACE}"
68+
oc adm policy add-role-to-group system:image-puller system:serviceaccounts:"${OLM_NAMESPACE}" --namespace "${ON_CLUSTER_BUILDS_NAMESPACE}"
69+
oc adm policy add-role-to-group system:image-puller system:serviceaccounts:"${OPERATORS_NAMESPACE}" --namespace "${ON_CLUSTER_BUILDS_NAMESPACE}"
6770

6871
local index_dorkerfile_path="olm-catalog/serverless-operator-index/Dockerfile"
6972

@@ -248,26 +251,26 @@ function build_image() {
248251

249252
logger.info "Using ${tmp_dockerfile} as Dockerfile"
250253

251-
if ! oc get buildconfigs "$name" -n "$OLM_NAMESPACE" >/dev/null 2>&1; then
254+
if ! oc get buildconfigs "$name" -n "$ON_CLUSTER_BUILDS_NAMESPACE" >/dev/null 2>&1; then
252255
logger.info "Create an image build for ${name}"
253-
oc -n "${OLM_NAMESPACE}" new-build \
256+
oc -n "${ON_CLUSTER_BUILDS_NAMESPACE}" new-build \
254257
--strategy=docker --name "$name" --dockerfile "$(cat "${tmp_dockerfile}")"
255258

256-
from_kind=$(oc get BuildConfig -n "${OLM_NAMESPACE}" "$name" -o json | \
259+
from_kind=$(oc get BuildConfig -n "${ON_CLUSTER_BUILDS_NAMESPACE}" "$name" -o json | \
257260
jq -r '.spec.strategy.dockerStrategy.from.kind')
258261
if [ "ImageStreamTag" = "$from_kind" ]; then
259-
image_stream_tag=$(oc get BuildConfig -n "${OLM_NAMESPACE}" "$name" -o json | \
262+
image_stream_tag=$(oc get BuildConfig -n "${ON_CLUSTER_BUILDS_NAMESPACE}" "$name" -o json | \
260263
jq -r '.spec.strategy.dockerStrategy.from.name')
261264

262265
logger.info "Wait for the ${image_stream_tag} ImageStreamTag to be imported"
263-
timeout 60 "! oc get imagestreamtag -n \"${OLM_NAMESPACE}\" \"$image_stream_tag\" -o json | jq -re .image.dockerImageReference"
266+
timeout 60 "! oc get imagestreamtag -n \"${ON_CLUSTER_BUILDS_NAMESPACE}\" \"$image_stream_tag\" -o json | jq -re .image.dockerImageReference"
264267
fi
265268
else
266269
logger.info "${name} image build is already created"
267270
fi
268271

269272
logger.info 'Build the image in the cluster-internal registry.'
270-
oc -n "${OLM_NAMESPACE}" start-build "${name}" --from-dir "${from_dir}" -F
273+
oc -n "${ON_CLUSTER_BUILDS_NAMESPACE}" start-build "${name}" --from-dir "${from_dir}" -F
271274
}
272275

273276
function delete_catalog_source {
@@ -276,9 +279,9 @@ function delete_catalog_source {
276279
oc delete service --ignore-not-found=true -n "$OLM_NAMESPACE" serverless-index
277280
oc delete deployment --ignore-not-found=true -n "$OLM_NAMESPACE" serverless-index
278281
oc delete configmap --ignore-not-found=true -n "$OLM_NAMESPACE" serverless-index-sha1sums
279-
oc delete buildconfig --ignore-not-found=true -n "$OLM_NAMESPACE" serverless-index
282+
oc delete buildconfig --ignore-not-found=true -n "$ON_CLUSTER_BUILDS_NAMESPACE" serverless-index
280283
oc delete configmap --ignore-not-found=true -n "$OLM_NAMESPACE" serverless-bundle-sha1sums
281-
oc delete buildconfig --ignore-not-found=true -n "$OLM_NAMESPACE" serverless-bundle
284+
oc delete buildconfig --ignore-not-found=true -n "$ON_CLUSTER_BUILDS_NAMESPACE" serverless-bundle
282285
logger.info "Wait for the ${OPERATOR} pod to disappear"
283286
timeout 300 "[[ \$(oc get pods -n ${OPERATORS_NAMESPACE} | grep -c ${OPERATOR}) -gt 0 ]]"
284287
oc delete imagecontentsourcepolicy --ignore-not-found=true serverless-image-content-source-policy

hack/lib/vars.bash

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export OPERATOR="${OPERATOR:-serverless-operator}"
4848
export SCALE_UP="${SCALE_UP:--1}"
4949

5050
export OLM_NAMESPACE="${OLM_NAMESPACE:-openshift-marketplace}"
51+
export ON_CLUSTER_BUILDS_NAMESPACE="${ON_CLUSTER_BUILDS_NAMESPACE:-openshift-serverless-builds}"
5152
export OPERATORS_NAMESPACE="${OPERATORS_NAMESPACE:-openshift-serverless}"
5253
export SERVING_NAMESPACE="${SERVING_NAMESPACE:-knative-serving}"
5354
export INGRESS_NAMESPACE="${INGRESS_NAMESPACE:-knative-serving-ingress}"
@@ -57,7 +58,7 @@ export TRACING_NAMESPACE="${TRACING_NAMESPACE:-knative-tracing}"
5758
export TRACING_BACKEND="${TRACING_BACKEND:-tempo}"
5859

5960
declare -a SYSTEM_NAMESPACES
60-
SYSTEM_NAMESPACES=("${TRACING_NAMESPACE}" "${OPERATORS_NAMESPACE}")
61+
SYSTEM_NAMESPACES=("${TRACING_NAMESPACE}" "${OPERATORS_NAMESPACE}" "${ON_CLUSTER_BUILDS_NAMESPACE}")
6162
export SYSTEM_NAMESPACES
6263
export UPGRADE_SERVERLESS="${UPGRADE_SERVERLESS:-"true"}"
6364
export UPGRADE_CLUSTER="${UPGRADE_CLUSTER:-"false"}"

0 commit comments

Comments
 (0)