Skip to content

Commit

Permalink
move all catalogs to internal registry
Browse files Browse the repository at this point in the history
Signed-off-by: Per Goncalves da Silva <[email protected]>
  • Loading branch information
Per Goncalves da Silva committed Jun 17, 2024
1 parent e20bf75 commit 93d971b
Show file tree
Hide file tree
Showing 27 changed files with 111 additions and 343 deletions.
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,10 @@ image-registry: ## Setup in-cluster image registry

.PHONY: build-and-load-e2e-fixture-images
build-and-load-e2e-fixture-images: # Build e2e fixture images and either kind-load or push them to an on-cluster registry
# build and kind-load fixture images
scripts/e2e_test_fixtures.sh --kind-load

# push the test-catalog to an on-cluster registry
./scripts/publish_e2e_catalog.sh $(E2E_REGISTRY_NAMESPACE) $(CATALOG_IMG)
./scripts/publish_e2e_catalog.sh "test/images/busybox-index-v1" "indexv1" "$(E2E_REGISTRY_NAMESPACE)" "$(REGISTRY_ROOT)/busybox-dependencies-index:1.0.0-with-ListBundles-method-${OPERATOR_REGISTRY_VERSION}"
./scripts/publish_e2e_catalog.sh "test/images/busybox-index-v2" "indexv2" "$(E2E_REGISTRY_NAMESPACE)" "$(REGISTRY_ROOT)/busybox-dependencies-index:2.0.0-with-ListBundles-method-${OPERATOR_REGISTRY_VERSION}"
./scripts/publish_e2e_catalog.sh "test/images/busybox-index-v2" "test-catalog" "$(E2E_REGISTRY_NAMESPACE)" "$(REGISTRY_ROOT)/test-catalog:e2e"

.PHONY: deploy
OLM_IMAGE := quay.io/operator-framework/olm:local
Expand Down
7 changes: 0 additions & 7 deletions pkg/lib/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,5 @@ func InferImagePullPolicy(image string) corev1.PullPolicy {
if strings.Contains(image, "@") {
return corev1.PullIfNotPresent
}

// Ensure test registry images are pulled only if needed
// These will normally be loaded through kind load docker-image
// This is also helps support the e2e fixture image re-build flow (see e2e GHA)
if strings.HasPrefix(image, "quay.io/olmtest/test-catalog") {
return corev1.PullIfNotPresent
}
return corev1.PullAlways
}
24 changes: 0 additions & 24 deletions scripts/e2e_test_fixtures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ source .bingo/variables.env
# Default values
KIND=${KIND:-kind}
KIND_CLUSTER_NAME=${KIND_CLUSTER_NAME:-kind-olmv0}
OPM_VERSION=$(go list -m github.com/operator-framework/operator-registry | cut -d" " -f2 | sed 's/^v//')
PUSH=false
SAVE=false
CONTAINER_RUNTIME=docker
Expand Down Expand Up @@ -133,16 +132,6 @@ if [ "$BUILD" = "true" ]; then
${CONTAINER_RUNTIME} tag "${INDEX_V2}" "${TEST_CATALOG_IMAGE}"
fi

# Assumes images are already built, kind cluster is running, and kubeconfig is set
if [ "$LOAD_KIND" = true ]; then
${KIND} load docker-image --name="${KIND_CLUSTER_NAME}" "${BUNDLE_V1_IMAGE}"
${KIND} load docker-image --name="${KIND_CLUSTER_NAME}" "${BUNDLE_V1_DEP_IMAGE}"
${KIND} load docker-image --name="${KIND_CLUSTER_NAME}" "${BUNDLE_V2_IMAGE}"
${KIND} load docker-image --name="${KIND_CLUSTER_NAME}" "${BUNDLE_V2_DEP_IMAGE}"
${KIND} load docker-image --name="${KIND_CLUSTER_NAME}" "${INDEX_V1}"
${KIND} load docker-image --name="${KIND_CLUSTER_NAME}" "${INDEX_V2}"
fi

# Assumes images are already built
if [ "${SAVE}" = true ]; then
${CONTAINER_RUNTIME} save "${BUNDLE_V1_IMAGE}" | gzip > bundlev1.tar.gz
Expand All @@ -154,16 +143,3 @@ if [ "${SAVE}" = true ]; then
${CONTAINER_RUNTIME} save "${INDEX_V1}" | gzip > indexv1.tar.gz
${CONTAINER_RUNTIME} save "${INDEX_V2}" | gzip > indexv2.tar.gz
fi

# Assumes images are already built
if [ "$PUSH" = true ]; then
# push bundles
${CONTAINER_RUNTIME} push "${BUNDLE_V1_IMAGE}"
${CONTAINER_RUNTIME} push "${BUNDLE_V1_IMAGE}"
${CONTAINER_RUNTIME} push "${BUNDLE_V1_IMAGE}"
${CONTAINER_RUNTIME} push "${BUNDLE_V1_IMAGE}"

# push indexes
${CONTAINER_RUNTIME} push "${INDEX_V1}"
${CONTAINER_RUNTIME} push "${INDEX_V2}"
fi
44 changes: 15 additions & 29 deletions scripts/publish_e2e_catalog.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,30 @@
#! /bin/bash

set -x
set -o errexit
set -o nounset
set -o pipefail

help="
build-push-e2e-catalog.sh is a script to build and push the e2e catalog image using kaniko.
Usage:
build-push-e2e-catalog.sh [NAMESPACE] [TAG]
Argument Descriptions:
- NAMESPACE is the namespace the kaniko Job should be created in
- TAG is the full tag used to build and push the catalog image
"

if [[ "$#" -ne 2 ]]; then
echo "Illegal number of arguments passed"
echo "${help}"
exit 1
fi

namespace=$1
tag=$2
src=$1
name=$2
namespace=$3
dest=$4

OPM_VERSION=${OPM_VERSION:-"latest"}

echo "${namespace}" "${tag}"

# Delete existing configmaps
kubectl delete configmap -n "${namespace}" test-catalog.dockerfile --ignore-not-found
kubectl delete configmap -n "${namespace}" test-catalog.build-contents --ignore-not-found
kubectl delete configmap -n "${namespace}" "${name}.dockerfile" --ignore-not-found
kubectl delete configmap -n "${namespace}" "${name}.build-contents" --ignore-not-found

kubectl create configmap -n "${namespace}" --from-file=test/images/test-catalog/dockerfile test-catalog.dockerfile
kubectl create configmap -n "${namespace}" --from-file=test/images/test-catalog/configs test-catalog.build-contents
kubectl create configmap -n "${namespace}" --from-file="${src}/dockerfile" "${name}.dockerfile"
kubectl create configmap -n "${namespace}" --from-file="${src}/configs" "${name}.build-contents"

kubectl apply -f - << EOF
# Create the kaniko job
kubectl create -f - << EOF
apiVersion: batch/v1
kind: Job
metadata:
name: kaniko
generateName: "kaniko-"
namespace: "${namespace}"
spec:
template:
Expand All @@ -49,7 +35,7 @@ spec:
args: [ "--build-arg=OPM_VERSION=${OPM_VERSION}",
"--dockerfile=/workspace/dockerfile",
"--context=/workspace",
"--destination=${tag}",
"--destination=${dest}",
"--verbosity=trace",
"--skip-tls-verify"]
volumeMounts:
Expand All @@ -61,13 +47,13 @@ spec:
volumes:
- name: dockerfile
configMap:
name: test-catalog.dockerfile
name: "${name}.dockerfile"
items:
- key: dockerfile
path: dockerfile
- name: build-contents
configMap:
name: test-catalog.build-contents
name: "${name}.build-contents"
EOF

kubectl wait --for=condition=Complete -n "${namespace}" jobs/kaniko --timeout=60s
Original file line number Diff line number Diff line change
@@ -1,3 +1,92 @@
{
"schema": "olm.package",
"name": "busybox",
"defaultChannel": "alpha"
}
{
"schema": "olm.channel",
"name": "alpha",
"package": "busybox",
"entries": [
{
"name": "busybox.v1.0.0"
}
]
}
{
"schema": "olm.bundle",
"name": "busybox.v1.0.0",
"package": "busybox",
"image": "quay.io/olmtest/busybox-bundle:1.0.0",
"properties": [
{
"type": "olm.gvk.required",
"value": {
"group": "olm.test.io",
"kind": "Foo",
"version": "v1"
}
},
{
"type": "olm.package",
"value": {
"packageName": "busybox",
"version": "1.0.0"
}
},
{
"type": "olm.csv.metadata",
"value": {
"apiServiceDefinitions": {},
"crdDescriptions": {
"required": [
{
"name": "foos.olm.test.io",
"version": "v1",
"kind": "Foo",
"displayName": "Foo",
"description": "Foo resources for testing dependencies"
}
]
},
"description": "A busybox CSV.\n",
"displayName": "busybox",
"installModes": [
{
"type": "OwnNamespace",
"supported": true
},
{
"type": "SingleNamespace",
"supported": true
},
{
"type": "MultiNamespace",
"supported": true
},
{
"type": "AllNamespaces",
"supported": true
}
],
"maturity": "alpha",
"provider": {
"name": "Red Hat"
}
}
}
],
"relatedImages": [
{
"name": "",
"image": "busybox"
},
{
"name": "",
"image": "quay.io/olmtest/busybox-bundle:1.0.0"
}
]
}
{
"schema": "olm.package",
"name": "busybox-dependency",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ FROM quay.io/operator-framework/opm:${OPM_VERSION}
LABEL operators.operatorframework.io.index.configs.v1=/configs

# Copy declarative config root into image at /configs and pre-populate serve cache
COPY configs /configs
COPY /configs /configs
RUN ["/bin/opm", "serve", "/configs", "--cache-dir=/tmp/cache", "--cache-only"]

# Configure the entrypoint and command
Expand Down
2 changes: 2 additions & 0 deletions test/images/busybox-index-v2/configs/.indexignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/expected_all.json
..*
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,3 @@
}
]
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ FROM quay.io/operator-framework/opm:${OPM_VERSION}
LABEL operators.operatorframework.io.index.configs.v1=/configs

# Copy declarative config root into image at /configs and pre-populate serve cache
ARG CONFIGS_DIR=/configs
COPY ${CONFIGS_DIR} /configs
COPY /configs /configs
RUN ["/bin/opm", "serve", "/configs", "--cache-dir=/tmp/cache", "--cache-only"]

# Configure the entrypoint and command
Expand Down
89 changes: 0 additions & 89 deletions test/images/busybox-index/indexv1/busybox/catalog.json

This file was deleted.

Loading

0 comments on commit 93d971b

Please sign in to comment.