Skip to content

Commit

Permalink
fix install kwok (#708)
Browse files Browse the repository at this point in the history
Signed-off-by: bzsuni <[email protected]>
  • Loading branch information
bzsuni authored Aug 29, 2023
1 parent dc8b28e commit 182767f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 39 deletions.
16 changes: 13 additions & 3 deletions Makefile.defs
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,25 @@ 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
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 ?=
Expand Down Expand Up @@ -194,6 +203,7 @@ WEB_PORT="63382"
HTTP_PROXY ?=
E2E_CHINA_IMAGE_REGISTRY ?= false

# kwok
E2E_INSTALL_KWOK ?= true

KWOK_VERSION ?= v0.4.0

1 change: 1 addition & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ; \
Expand Down
42 changes: 6 additions & 36 deletions test/scripts/installKwok.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF > "${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"

0 comments on commit 182767f

Please sign in to comment.