Skip to content

Commit 601fb2c

Browse files
committed
Remove kaniko / extension-developer-e2e cleanup
Removes use of kaniko, which is now an archived project, in favor of using tools we already have at our disposal. Also attempted to clean up the Makefile and setup script a bit, as well as a fail-early check in the test to make it clearer that some env is required. Signed-off-by: Daniel Franz <[email protected]>
1 parent 8cf5bda commit 601fb2c

File tree

4 files changed

+30
-132
lines changed

4 files changed

+30
-132
lines changed

Makefile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,13 @@ E2E_REGISTRY_NAME := docker-registry
223223
E2E_REGISTRY_NAMESPACE := operator-controller-e2e
224224

225225
export REG_PKG_NAME := registry-operator
226-
export LOCAL_REGISTRY_HOST := $(E2E_REGISTRY_NAME).$(E2E_REGISTRY_NAMESPACE).svc:5000
227-
export CLUSTER_REGISTRY_HOST := localhost:30000
228-
export E2E_TEST_CATALOG_V1 := e2e/test-catalog:v1
229-
export E2E_TEST_CATALOG_V2 := e2e/test-catalog:v2
230-
export CATALOG_IMG := $(LOCAL_REGISTRY_HOST)/$(E2E_TEST_CATALOG_V1)
226+
export CLUSTER_REGISTRY_HOST := $(E2E_REGISTRY_NAME).$(E2E_REGISTRY_NAMESPACE).svc:5000
227+
export LOCAL_REGISTRY_HOST := localhost:30000
228+
export E2E_TEST_CATALOG := e2e/test-catalog:v1
229+
export CATALOG_IMG := $(CLUSTER_REGISTRY_HOST)/$(E2E_TEST_CATALOG)
231230
.PHONY: test-ext-dev-e2e
232-
test-ext-dev-e2e: $(OPERATOR_SDK) $(KUSTOMIZE) $(KIND) #HELP Run extension create, upgrade and delete tests.
233-
test/extension-developer-e2e/setup.sh $(OPERATOR_SDK) $(CONTAINER_RUNTIME) $(KUSTOMIZE) $(KIND) $(KIND_CLUSTER_NAME) $(E2E_REGISTRY_NAMESPACE)
231+
test-ext-dev-e2e: $(OPERATOR_SDK) $(KUSTOMIZE) #HELP Run extension create, upgrade and delete tests.
232+
test/extension-developer-e2e/setup.sh $(OPERATOR_SDK) $(CONTAINER_RUNTIME) $(KUSTOMIZE) ${LOCAL_REGISTRY_HOST} ${CLUSTER_REGISTRY_HOST}
234233
go test -count=1 -v ./test/extension-developer-e2e/...
235234

236235
UNIT_TEST_DIRS := $(shell go list ./... | grep -v /test/)

test/experimental-e2e/experimental_e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func TestWebhookSupport(t *testing.T) {
119119
Source: ocv1.CatalogSource{
120120
Type: ocv1.SourceTypeImage,
121121
Image: &ocv1.ImageSource{
122-
Ref: fmt.Sprintf("%s/e2e/test-catalog:v1", os.Getenv("LOCAL_REGISTRY_HOST")),
122+
Ref: fmt.Sprintf("%s/e2e/test-catalog:v1", os.Getenv("CLUSTER_REGISTRY_HOST")),
123123
PollIntervalMinutes: ptr.To(1),
124124
},
125125
},

test/extension-developer-e2e/extension_developer_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ func TestExtensionDeveloper(t *testing.T) {
3232
require.NoError(t, corev1.AddToScheme(scheme))
3333
require.NoError(t, rbacv1.AddToScheme(scheme))
3434

35+
require.NotEmpty(t, os.Getenv("CATALOG_IMG"), "environment variable CATALOG_IMG must be set")
36+
require.NotEmpty(t, os.Getenv("REG_PKG_NAME"), "environment variable REG_PKG_NAME must be set")
37+
3538
c, err := client.New(cfg, client.Options{Scheme: scheme})
3639
require.NoError(t, err)
3740

test/extension-developer-e2e/setup.sh

Lines changed: 20 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,26 @@ following bundle formats:
1111
This script will ensure that all images built are loaded onto
1212
a KinD cluster with the name specified in the arguments.
1313
The following environment variables are required for configuring this script:
14-
- \$CATALOG_IMG - the tag for the catalog image that contains the registry+v1 bundle.
14+
- \$E2E_TEST_CATALOG - the tag for the catalog image that contains the registry+v1 bundle.
1515
- \$REG_PKG_NAME - the name of the package for the extension that uses the registry+v1 bundle format.
16-
- \$LOCAL_REGISTRY_HOST - hostname:port of the local docker-registry
1716
setup.sh also takes 5 arguments.
1817
1918
Usage:
20-
setup.sh [OPERATOR_SDK] [CONTAINER_RUNTIME] [KUSTOMIZE] [KIND] [KIND_CLUSTER_NAME] [NAMESPACE]
19+
setup.sh [OPERATOR_SDK] [CONTAINER_RUNTIME] [KUSTOMIZE] [LOCAL_REGISTRY_HOST] [CLUSTER_REGISTRY_HOST]
2120
"
2221

2322
########################################
2423
# Input validation
2524
########################################
2625

27-
if [[ "$#" -ne 6 ]]; then
26+
if [[ "$#" -ne 5 ]]; then
2827
echo "Illegal number of arguments passed"
2928
echo "${help}"
3029
exit 1
3130
fi
3231

33-
if [[ -z "${CATALOG_IMG}" ]]; then
34-
echo "\$CATALOG_IMG is required to be set"
32+
if [[ -z "${E2E_TEST_CATALOG}" ]]; then
33+
echo "\$E2E_TEST_CATALOG is required to be set"
3534
echo "${help}"
3635
exit 1
3736
fi
@@ -42,12 +41,6 @@ if [[ -z "${REG_PKG_NAME}" ]]; then
4241
exit 1
4342
fi
4443

45-
if [[ -z "${LOCAL_REGISTRY_HOST}" ]]; then
46-
echo "\$LOCAL_REGISTRY_HOST is required to be set"
47-
echo "${help}"
48-
exit 1
49-
fi
50-
5144
########################################
5245
# Setup temp dir and local variables
5346
########################################
@@ -64,15 +57,19 @@ mkdir -p "${REG_DIR}"
6457
operator_sdk=$1
6558
container_tool=$2
6659
kustomize=$3
67-
kind=$4
68-
kcluster_name=$5
69-
namespace=$6
60+
# The path we use to push the image from _outside_ the cluster
61+
local_registry_host=$4
62+
# The path we use _inside_ the cluster
63+
cluster_registry_host=$5
64+
65+
catalog_push_tag="${local_registry_host}/${E2E_TEST_CATALOG}"
66+
reg_pkg_name="${REG_PKG_NAME}"
7067

7168
reg_img="${DOMAIN}/registry:v0.0.1"
72-
reg_bundle_img="${LOCAL_REGISTRY_HOST}/bundles/registry-v1/registry-bundle:v0.0.1"
69+
reg_bundle_path="bundles/registry-v1/registry-bundle:v0.0.1"
7370

74-
catalog_img="${CATALOG_IMG}"
75-
reg_pkg_name="${REG_PKG_NAME}"
71+
reg_bundle_img="${cluster_registry_host}/${reg_bundle_path}"
72+
reg_bundle_push_tag="${local_registry_host}/${reg_bundle_path}"
7673

7774
########################################
7875
# Create the registry+v1 based extension
@@ -84,7 +81,7 @@ reg_pkg_name="${REG_PKG_NAME}"
8481
# NOTE: This is a rough edge that users will experience
8582

8683
# The Makefile in the project scaffolded by operator-sdk uses an SDK binary
87-
# in the path path if it is present. Override via `export` to ensure we use
84+
# in the path if it is present. Override via `export` to ensure we use
8885
# the same version that we scaffolded with.
8986
# NOTE: this is a rough edge that users will experience
9087

@@ -102,7 +99,8 @@ reg_pkg_name="${REG_PKG_NAME}"
10299
make docker-build IMG="${reg_img}" && \
103100
sed -i -e 's/$(OPERATOR_SDK) generate kustomize manifests -q/$(OPERATOR_SDK) generate kustomize manifests -q --interactive=false/g' Makefile && \
104101
make bundle IMG="${reg_img}" VERSION=0.0.1 && \
105-
make bundle-build BUNDLE_IMG="${reg_bundle_img}"
102+
make bundle-build BUNDLE_IMG="${reg_bundle_push_tag}"
103+
${container_tool} push ${reg_bundle_push_tag} --tls-verify=false
106104
)
107105

108106
###############################
@@ -149,107 +147,5 @@ cat <<EOF > "${TMP_ROOT}"/catalog/index.yaml
149147
}
150148
EOF
151149

152-
# Add a .indexignore to make catalogd ignore
153-
# reading the symlinked ..* files that are created when
154-
# mounting a ConfigMap
155-
cat <<EOF > "${TMP_ROOT}"/catalog/.indexignore
156-
..*
157-
EOF
158-
159-
kubectl create configmap -n "${namespace}" --from-file="${TMP_ROOT}"/catalog.Dockerfile extension-dev-e2e.dockerfile
160-
kubectl create configmap -n "${namespace}" --from-file="${TMP_ROOT}"/catalog extension-dev-e2e.build-contents
161-
162-
kubectl apply -f - << EOF
163-
apiVersion: batch/v1
164-
kind: Job
165-
metadata:
166-
name: kaniko
167-
namespace: "${namespace}"
168-
spec:
169-
template:
170-
spec:
171-
containers:
172-
- name: kaniko
173-
image: gcr.io/kaniko-project/executor:latest
174-
args: ["--dockerfile=/workspace/catalog.Dockerfile",
175-
"--context=/workspace/",
176-
"--destination=${catalog_img}",
177-
"--skip-tls-verify"]
178-
volumeMounts:
179-
- name: dockerfile
180-
mountPath: /workspace/
181-
- name: build-contents
182-
mountPath: /workspace/catalog/
183-
restartPolicy: Never
184-
volumes:
185-
- name: dockerfile
186-
configMap:
187-
name: extension-dev-e2e.dockerfile
188-
items:
189-
- key: catalog.Dockerfile
190-
path: catalog.Dockerfile
191-
- name: build-contents
192-
configMap:
193-
name: extension-dev-e2e.build-contents
194-
EOF
195-
196-
kubectl wait --for=condition=Complete -n "${namespace}" jobs/kaniko --timeout=60s
197-
198-
# Make sure all files are removable. This is necessary because
199-
# the Makefiles generated by the Operator-SDK have targets
200-
# that install binaries under the bin/ directory. Those binaries
201-
# don't have write permissions so they can't be removed unless
202-
# we ensure they have the write permissions
203-
chmod -R +w "${REG_DIR}/bin"
204-
205-
# Load the bundle image into the docker-registry
206-
207-
kubectl create configmap -n "${namespace}" --from-file="${REG_DIR}/bundle.Dockerfile" operator-controller-e2e-${reg_pkg_name}.root
208-
209-
tgz="${REG_DIR}/manifests.tgz"
210-
tar czf "${tgz}" -C "${REG_DIR}" bundle
211-
kubectl create configmap -n "${namespace}" --from-file="${tgz}" operator-controller-${reg_pkg_name}.manifests
212-
213-
kubectl apply -f - << EOF
214-
apiVersion: batch/v1
215-
kind: Job
216-
metadata:
217-
name: "kaniko-${reg_pkg_name}"
218-
namespace: "${namespace}"
219-
spec:
220-
template:
221-
spec:
222-
initContainers:
223-
- name: copy-manifests
224-
image: busybox
225-
command: ['sh', '-c', 'cp /manifests-data/* /manifests']
226-
volumeMounts:
227-
- name: manifests
228-
mountPath: /manifests
229-
- name: manifests-data
230-
mountPath: /manifests-data
231-
containers:
232-
- name: kaniko
233-
image: gcr.io/kaniko-project/executor:latest
234-
args: ["--dockerfile=/workspace/bundle.Dockerfile",
235-
"--context=tar:///workspace/manifests/manifests.tgz",
236-
"--destination=${reg_bundle_img}",
237-
"--skip-tls-verify"]
238-
volumeMounts:
239-
- name: dockerfile
240-
mountPath: /workspace/
241-
- name: manifests
242-
mountPath: /workspace/manifests/
243-
restartPolicy: Never
244-
volumes:
245-
- name: dockerfile
246-
configMap:
247-
name: operator-controller-e2e-${reg_pkg_name}.root
248-
- name: manifests
249-
emptyDir: {}
250-
- name: manifests-data
251-
configMap:
252-
name: operator-controller-${reg_pkg_name}.manifests
253-
EOF
254-
255-
kubectl wait --for=condition=Complete -n "${namespace}" jobs/kaniko-${reg_pkg_name} --timeout=60s
150+
${container_tool} build -f ${TMP_ROOT}/catalog.Dockerfile -t ${catalog_push_tag}
151+
${container_tool} push ${catalog_push_tag} --tls-verify=false

0 commit comments

Comments
 (0)