Skip to content

Commit 5dfcc76

Browse files
authored
Remove kaniko / extension-developer-e2e cleanup (#2116)
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 5dfcc76

File tree

5 files changed

+39
-134
lines changed

5 files changed

+39
-134
lines changed

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,14 @@ 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
226+
export CLUSTER_REGISTRY_HOST := $(E2E_REGISTRY_NAME).$(E2E_REGISTRY_NAMESPACE).svc:5000
227+
export LOCAL_REGISTRY_HOST := localhost:30000
228228
export E2E_TEST_CATALOG_V1 := e2e/test-catalog:v1
229229
export E2E_TEST_CATALOG_V2 := e2e/test-catalog:v2
230-
export CATALOG_IMG := $(LOCAL_REGISTRY_HOST)/$(E2E_TEST_CATALOG_V1)
230+
export CATALOG_IMG := $(CLUSTER_REGISTRY_HOST)/$(E2E_TEST_CATALOG_V1)
231231
.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)
232+
test-ext-dev-e2e: $(OPERATOR_SDK) $(KUSTOMIZE) #HELP Run extension create, upgrade and delete tests.
233+
test/extension-developer-e2e/setup.sh $(OPERATOR_SDK) $(CONTAINER_RUNTIME) $(KUSTOMIZE) ${LOCAL_REGISTRY_HOST} ${CLUSTER_REGISTRY_HOST}
234234
go test -count=1 -v ./test/extension-developer-e2e/...
235235

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

test/e2e/cluster_extension_install_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ func TestClusterExtensionInstallReResolvesWhenCatalogIsPatched(t *testing.T) {
730730

731731
// patch imageRef tag on test-catalog image with v2 image
732732
t.Log("By patching the catalog ImageRef to point to the v2 catalog")
733-
updatedCatalogImage := fmt.Sprintf("%s/e2e/test-catalog:v2", os.Getenv("LOCAL_REGISTRY_HOST"))
733+
updatedCatalogImage := fmt.Sprintf("%s/e2e/test-catalog:v2", os.Getenv("CLUSTER_REGISTRY_HOST"))
734734
err := patchTestCatalog(context.Background(), testCatalogName, updatedCatalogImage)
735735
require.NoError(t, err)
736736
require.EventuallyWithT(t, func(ct *assert.CollectT) {
@@ -759,12 +759,12 @@ func TestClusterExtensionInstallReResolvesWhenNewCatalog(t *testing.T) {
759759

760760
// Tag the image with the new tag
761761
var err error
762-
v1Image := fmt.Sprintf("%s/%s", os.Getenv("CLUSTER_REGISTRY_HOST"), os.Getenv("E2E_TEST_CATALOG_V1"))
762+
v1Image := fmt.Sprintf("%s/%s", os.Getenv("LOCAL_REGISTRY_HOST"), os.Getenv("E2E_TEST_CATALOG_V1"))
763763
err = crane.Tag(v1Image, latestImageTag, crane.Insecure)
764764
require.NoError(t, err)
765765

766766
// create a test-catalog with latest image tag
767-
latestCatalogImage := fmt.Sprintf("%s/e2e/test-catalog:latest", os.Getenv("LOCAL_REGISTRY_HOST"))
767+
latestCatalogImage := fmt.Sprintf("%s/e2e/test-catalog:latest", os.Getenv("CLUSTER_REGISTRY_HOST"))
768768
extensionCatalog, err := createTestCatalog(context.Background(), testCatalogName, latestCatalogImage)
769769
require.NoError(t, err)
770770
clusterExtensionName := fmt.Sprintf("clusterextension-%s", rand.String(8))
@@ -810,7 +810,7 @@ func TestClusterExtensionInstallReResolvesWhenNewCatalog(t *testing.T) {
810810

811811
// update tag on test-catalog image with v2 image
812812
t.Log("By updating the catalog tag to point to the v2 catalog")
813-
v2Image := fmt.Sprintf("%s/%s", os.Getenv("CLUSTER_REGISTRY_HOST"), os.Getenv("E2E_TEST_CATALOG_V2"))
813+
v2Image := fmt.Sprintf("%s/%s", os.Getenv("LOCAL_REGISTRY_HOST"), os.Getenv("E2E_TEST_CATALOG_V2"))
814814
err = crane.Tag(v2Image, latestImageTag, crane.Insecure)
815815
require.NoError(t, err)
816816
require.EventuallyWithT(t, func(ct *assert.CollectT) {

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: 26 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_V1 - 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_V1}" ]]; then
33+
echo "\$E2E_TEST_CATALOG_V1 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,25 @@ 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+
tls_flag=""
66+
if [[ "$container_tool" == "podman" ]]; then
67+
echo "Using podman container runtime; adding tls disable flag"
68+
tls_flag="--tls-verify=false"
69+
fi
70+
71+
catalog_push_tag="${local_registry_host}/${E2E_TEST_CATALOG_V1}"
72+
reg_pkg_name="${REG_PKG_NAME}"
7073

7174
reg_img="${DOMAIN}/registry:v0.0.1"
72-
reg_bundle_img="${LOCAL_REGISTRY_HOST}/bundles/registry-v1/registry-bundle:v0.0.1"
75+
reg_bundle_path="bundles/registry-v1/registry-bundle:v0.0.1"
7376

74-
catalog_img="${CATALOG_IMG}"
75-
reg_pkg_name="${REG_PKG_NAME}"
77+
reg_bundle_img="${cluster_registry_host}/${reg_bundle_path}"
78+
reg_bundle_push_tag="${local_registry_host}/${reg_bundle_path}"
7679

7780
########################################
7881
# Create the registry+v1 based extension
@@ -84,7 +87,7 @@ reg_pkg_name="${REG_PKG_NAME}"
8487
# NOTE: This is a rough edge that users will experience
8588

8689
# 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
90+
# in the path if it is present. Override via `export` to ensure we use
8891
# the same version that we scaffolded with.
8992
# NOTE: this is a rough edge that users will experience
9093

@@ -102,7 +105,8 @@ reg_pkg_name="${REG_PKG_NAME}"
102105
make docker-build IMG="${reg_img}" && \
103106
sed -i -e 's/$(OPERATOR_SDK) generate kustomize manifests -q/$(OPERATOR_SDK) generate kustomize manifests -q --interactive=false/g' Makefile && \
104107
make bundle IMG="${reg_img}" VERSION=0.0.1 && \
105-
make bundle-build BUNDLE_IMG="${reg_bundle_img}"
108+
make bundle-build BUNDLE_IMG="${reg_bundle_push_tag}"
109+
${container_tool} push ${reg_bundle_push_tag} ${tls_flag}
106110
)
107111

108112
###############################
@@ -149,107 +153,5 @@ cat <<EOF > "${TMP_ROOT}"/catalog/index.yaml
149153
}
150154
EOF
151155

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
156+
${container_tool} build -f "${TMP_ROOT}/catalog.Dockerfile" -t "${catalog_push_tag}" "${TMP_ROOT}/"
157+
${container_tool} push ${catalog_push_tag} ${tls_flag}

0 commit comments

Comments
 (0)