From d827098642f8a090aff104574bb679b64370b378 Mon Sep 17 00:00:00 2001 From: Wainer dos Santos Moschetta Date: Fri, 26 Jan 2024 10:51:08 -0300 Subject: [PATCH 1/2] tests/e2e: allow to install non-local built images `./tests/e2e/operator.sh install` is still tightly coupled with the build phase, which happen to push images to a local registry, so the install tries to always start the registry service. Now suppose that you want to run `./tests/e2e/operator.sh install` stand-alone to install images from quay.io, then the registry service locally is not needed. Signed-off-by: Wainer dos Santos Moschetta --- tests/e2e/operator.sh | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/tests/e2e/operator.sh b/tests/e2e/operator.sh index 10b7c493..a834bc0e 100755 --- a/tests/e2e/operator.sh +++ b/tests/e2e/operator.sh @@ -17,14 +17,17 @@ source "${script_dir}/lib.sh" readonly ccruntime_overlay_basedir="${project_dir}/config/samples/ccruntime" # The operator namespace. readonly op_ns="confidential-containers-system" -# There should be a registry running locally on port 5000. -export IMG=localhost:5000/cc-operator:latest -export PRE_INSTALL_IMG=localhost:5000/reqs-payload +# If $IMG nor $PRE_INSTALL_IMG aren't exported then there should be a registry +# running locally on port 5000. +export IMG=${IMG:-localhost:5000/cc-operator:latest} +export PRE_INSTALL_IMG=${PRE_INSTALL_IMG:-localhost:5000/reqs-payload} # Build the operator and push images to a local registry. # build_operator () { - start_local_registry + if [[ "$IMG" =~ localhost ]];then + start_local_registry + fi # Note: git config --global --add safe.directory will always # append the target to .gitconfig without checking the @@ -47,7 +50,9 @@ build_operator () { # Build the reqs-payload and push images to a local registry. # build_pre_install_img() { - start_local_registry + if [[ "$PRE_INSTALL_IMG" =~ localhost ]];then + start_local_registry + fi pushd "${project_dir}/install/pre-install-payload" >/dev/null make reqs-image registry="${PRE_INSTALL_IMG}" \ @@ -83,8 +88,10 @@ handle_older_containerd() { # Install the operator. # install_operator() { - start_local_registry - + if [[ "$IMG" =~ localhost || \ + "$PRE_INSTALL_IMG" =~ localhost ]];then + start_local_registry + fi # The node should be 'worker' labeled local label="node.kubernetes.io/worker" if ! kubectl get node "$SAFE_HOST_NAME" -o jsonpath='{.metadata.labels}' \ @@ -154,7 +161,10 @@ install_ccruntime() { return 1 fi # To keep operator running, we should resume registry stopped during containerd restart. - start_local_registry + if [[ "$IMG" =~ localhost || \ + "$PRE_INSTALL_IMG" =~ localhost ]];then + start_local_registry + fi } # Uninstall the CC runtime. @@ -303,6 +313,9 @@ usage() { "install": install only, "wait_for_stabilization": wait for CoCo pods to be stable "uninstall": uninstall the operator. + environment variables : + IMG: the controller image (current: $IMG) + PRE_INSTALL_IMG: the pre-reqs image (current: $PRE_INSTALL_IMG) EOF } From 4d94a22127acdc7fd87c973ec4858f55516a7f0f Mon Sep 17 00:00:00 2001 From: Wainer dos Santos Moschetta Date: Fri, 26 Jan 2024 12:50:02 -0300 Subject: [PATCH 2/2] tests/e2e: allow to supersede the kata-payload By exporting $KATA_PAYLOAD_IMG variable the `./tests/e2e/operator.sh install` will replace the default kata-payload image. Signed-off-by: Wainer dos Santos Moschetta --- tests/e2e/operator.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/e2e/operator.sh b/tests/e2e/operator.sh index a834bc0e..606b60d0 100755 --- a/tests/e2e/operator.sh +++ b/tests/e2e/operator.sh @@ -21,6 +21,9 @@ readonly op_ns="confidential-containers-system" # running locally on port 5000. export IMG=${IMG:-localhost:5000/cc-operator:latest} export PRE_INSTALL_IMG=${PRE_INSTALL_IMG:-localhost:5000/reqs-payload} +# If $KATA_PAYLOAD_IMG isn't exported then use the image set on the +# configuration files. +export KATA_PAYLOAD_IMG=${KATA_PAYLOAD_IMG:-} # Build the operator and push images to a local registry. # @@ -133,6 +136,12 @@ install_ccruntime() { "quay.io/confidential-containers/reqs-payload" \ "${PRE_INSTALL_IMG}" + if [ -n "$KATA_PAYLOAD_IMG" ];then + kustomization_set_image "${ccruntime_overlay_basedir}/default" \ + "quay.io/kata-containers/kata-deploy" \ + "$KATA_PAYLOAD_IMG" + fi + pushd "$overlay_dir" >/dev/null kubectl create -k . popd >/dev/null @@ -316,6 +325,7 @@ usage() { environment variables : IMG: the controller image (current: $IMG) PRE_INSTALL_IMG: the pre-reqs image (current: $PRE_INSTALL_IMG) + KATA_PAYLOAD_IMG: the kata-payload image (current: the one set in configs) EOF }