From 182767f642dbbb691dad4f988c84ed2bcb6985a4 Mon Sep 17 00:00:00 2001 From: bzsuni <86399306+bzsuni@users.noreply.github.com> Date: Tue, 29 Aug 2023 11:31:48 +0800 Subject: [PATCH] fix install kwok (#708) Signed-off-by: bzsuni --- Makefile.defs | 16 +++++++++++--- test/Makefile | 1 + test/scripts/installKwok.sh | 42 ++++++------------------------------- 3 files changed, 20 insertions(+), 39 deletions(-) diff --git a/Makefile.defs b/Makefile.defs index aca39b2d1..967ec9d65 100644 --- a/Makefile.defs +++ b/Makefile.defs @@ -146,8 +146,12 @@ endif #====== pyroscope PYROSCOPE_CONTAINER_NAME := pyroscope -PYROSCOPE_IMAGE_NAME := pyroscope/pyroscope:latest PYROSCOPE_LOCAL_PORT := 8040 +ifeq ($(E2E_CHINA_IMAGE_REGISTRY),true) + PYROSCOPE_IMAGE_NAME ?= docker.m.daocloud.io/pyroscope/pyroscope:latest +else + PYROSCOPE_IMAGE_NAME ?= docker.io/pyroscope/pyroscope:latest +endif E2E_KIND_CLUSTER_NAME ?= egressgateway E2E_NAMESPACE ?= egressgateway @@ -155,7 +159,12 @@ E2E_RUNTIME_DIR := $(ROOT_DIR)/test/runtime E2E_KIND_KUBECONFIG_PATH := $(E2E_RUNTIME_DIR)/kubeconfig_$(E2E_KIND_CLUSTER_NAME).config E2E_LOG_FILE ?= $(E2E_RUNTIME_DIR)/e2edebugLog.txt E2E_GINKGO_REPORT_FILE ?= $(E2E_RUNTIME_DIR)/ginkgoreport.json -E2E_KIND_NODE_IMAGE ?= +E2E_KIND_NODE_IMAGE_TAG ?= v1.26.2 +ifeq ($(E2E_CHINA_IMAGE_REGISTRY),true) + E2E_KIND_NODE_IMAGE ?= docker.m.daocloud.io/kindest/node:$(E2E_KIND_NODE_IMAGE_TAG) +else + E2E_KIND_NODE_IMAGE ?= docker.io/kindest/node:$(E2E_KIND_NODE_IMAGE_TAG) +endif E2E_GINKGO_LABELS ?= E2E_GINKGO_OPTION ?= @@ -194,6 +203,7 @@ WEB_PORT="63382" HTTP_PROXY ?= E2E_CHINA_IMAGE_REGISTRY ?= false +# kwok E2E_INSTALL_KWOK ?= true - +KWOK_VERSION ?= v0.4.0 diff --git a/test/Makefile b/test/Makefile index 89f055391..48ce56722 100644 --- a/test/Makefile +++ b/test/Makefile @@ -96,6 +96,7 @@ install_kwok: if [ "$(E2E_INSTALL_KWOK)" == "true" ] ; then \ echo "install kwok" ; \ export INSTALL_TIME_OUT=$(INSTALL_TIME_OUT); \ + export KWOK_VERSION=$(KWOK_VERSION); \ export E2E_KIND_KUBECONFIG_PATH=$(E2E_KIND_KUBECONFIG_PATH); \ export https_proxy=$(HTTP_PROXY) ; \ bash ./scripts/installKwok.sh ; \ diff --git a/test/scripts/installKwok.sh b/test/scripts/installKwok.sh index 4f816d36a..4b689e34c 100644 --- a/test/scripts/installKwok.sh +++ b/test/scripts/installKwok.sh @@ -5,47 +5,17 @@ set -o errexit -o nounset -o pipefail set -x -# Temporary directory -KWOK_WORK_DIR=$(mktemp -d) -echo "KWOK_WORK_DIR=${KWOK_WORK_DIR}" - # KWOK repository KWOK_REPO=kubernetes-sigs/kwok -# Get latest -got="no" -for i in {0..12}; do - KWOK_LATEST_RELEASE=$(curl "https://api.github.com/repos/${KWOK_REPO}/releases/latest" | jq -r '.tag_name') - if [[ -z ${KWOK_LATEST_RELEASE} ]]; then - echo "${i}th, can not get tag, retry..." - sleep 2s - else - echo "KWOK_LATEST_RELEASE=${KWOK_LATEST_RELEASE}" - got="ok" - break - fi -done - -if [[ "${got}" = "no" ]]; then - echo "timeout to get tag" - exit 1 -fi - -cat < "${KWOK_WORK_DIR}/kustomization.yaml" -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -images: -- name: registry.k8s.io/kwok/kwok - newTag: "${KWOK_LATEST_RELEASE}" -resources: -- "https://github.com/${KWOK_REPO}/kustomize/kwok?ref=${KWOK_LATEST_RELEASE}" -EOF -kubectl --kubeconfig ${E2E_KIND_KUBECONFIG_PATH} kustomize "${KWOK_WORK_DIR}" > "${KWOK_WORK_DIR}/kwok.yaml" +# Deployment kwok and set up CRDs +curl -x "${https_proxy}" -L https://github.com/${KWOK_REPO}/releases/download/${KWOK_VERSION}/kwok.yaml | kubectl --kubeconfig ${E2E_KIND_KUBECONFIG_PATH} apply -f - || { echo failed install kwok; exit 1; } -kubectl --kubeconfig ${E2E_KIND_KUBECONFIG_PATH} apply -f "${KWOK_WORK_DIR}/kwok.yaml" +# Set up default CRs of Stages +curl -x "${https_proxy}" -L https://github.com/${KWOK_REPO}/releases/download/${KWOK_VERSION}/stage-fast.yaml | kubectl --kubeconfig ${E2E_KIND_KUBECONFIG_PATH} apply -f - || { echo failed install kwok; exit 1; } +# Wait pod running kubectl --kubeconfig ${E2E_KIND_KUBECONFIG_PATH} wait --for=condition=ready -l app=kwok-controller --timeout=${INSTALL_TIME_OUT} pod -n kube-system kubectl --kubeconfig ${E2E_KIND_KUBECONFIG_PATH} get po -l app=kwok-controller -n kube-system -echo -e "\033[35m Succeed to install KWOK \033[0m" -rm -rf ${KWOK_WORK_DIR}/kustomization.yaml || exit 0 +echo -e "\033[35m Succeed to install KWOK \033[0m" \ No newline at end of file