From 7eb123779eba6ccf66f873776665527084b4b816 Mon Sep 17 00:00:00 2001 From: Sehyo Chang Date: Sun, 8 Aug 2021 21:03:56 +0000 Subject: [PATCH] disable k8 if build image_version is supplied (#1400) This is for #1363. Disable building image if image version is supplied. This is useful in the Mac where building image might not work. In this case, we use image supplied built using Linux. Also, by default use proxy for accessing Minikube cluster since Docker for Mac doesn't map ports from Minikube to host automatically. --- Makefile | 9 ++++++--- k8-util/cluster/reset-minikube.sh | 11 +++++++++-- src/cluster/src/start/k8.rs | 4 ++++ tests/runner/src/utils/test_meta/environment.rs | 8 ++++++++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 727615d7da..15c88b2075 100644 --- a/Makefile +++ b/Makefile @@ -5,9 +5,9 @@ GIT_COMMIT=$(shell git rev-parse HEAD) DOCKER_TAG=$(VERSION)-$(GIT_COMMIT) DOCKER_REGISTRY=infinyon K8_CLUSTER?=$(shell ./k8-util/cluster/cluster-type.sh) -DOCKER_IMAGE=$(DOCKER_REGISTRY)/fluvio TARGET_MUSL=x86_64-unknown-linux-musl TARGET?= +IMAGE_VERSION?= # If set, this indicates that the image is pre-built and should not be built BUILD_PROFILE=$(if $(RELEASE),release,debug) CARGO_BUILDER=$(if $(findstring arm,$(TARGET)),cross,cargo) # If TARGET contains the substring "arm" FLUVIO_BIN=$(if $(TARGET),./target/$(TARGET)/$(BUILD_PROFILE)/fluvio,./target/$(BUILD_PROFILE)/fluvio) @@ -33,7 +33,7 @@ TEST_ENV_FLV_SPU_DELAY= TEST_ARG_SPU=--spu ${DEFAULT_SPU} TEST_ARG_LOG=--client-log ${CLIENT_LOG} --server-log ${SERVER_LOG} TEST_ARG_REPLICATION=-r ${REPL} -TEST_ARG_DEVELOP=--develop +TEST_ARG_DEVELOP=$(if $(IMAGE_VERSION),--image-version ${IMAGE_VERSION}, --develop) TEST_ARG_SKIP_CHECKS= TEST_ARG_EXTRA= TEST_ARG_CONSUMER_WAIT= @@ -54,6 +54,7 @@ helm_pkg: build-cli: install_rustup_target $(CARGO_BUILDER) build --bin fluvio $(RELEASE_FLAG) $(TARGET_FLAG) $(VERBOSE_FLAG) + build-cli-minimal: install_rustup_target # https://github.com/infinyon/fluvio/issues/1255 cargo build --bin fluvio $(RELEASE_FLAG) $(TARGET_FLAG) $(VERBOSE_FLAG) --no-default-features --features consumer --manifest-path ./src/cli/Cargo.toml @@ -125,7 +126,7 @@ k8-setup: # Kubernetes Tests smoke-test-k8: TEST_ARG_EXTRA=$(EXTRA_ARG) -smoke-test-k8: build_k8_image smoke-test +smoke-test-k8: smoke-test build_k8_image smoke-test-k8-tls: TEST_ARG_EXTRA=--tls $(EXTRA_ARG) smoke-test-k8-tls: build_k8_image smoke-test @@ -230,6 +231,8 @@ run-client-doc-test: install_rustup_target # In CI mode, do not build k8 image ifeq (${CI},true) build_k8_image: +else ifeq (${IMAGE_VERSION},true) +build_k8_image: else # When not in CI (i.e. development), build image before testing build_k8_image: fluvio_image diff --git a/k8-util/cluster/reset-minikube.sh b/k8-util/cluster/reset-minikube.sh index 9b445482ac..aeb954e4a9 100755 --- a/k8-util/cluster/reset-minikube.sh +++ b/k8-util/cluster/reset-minikube.sh @@ -1,9 +1,16 @@ #!/bin/bash # delete and re-install minikube ready for fluvio -# this defaults to docker and assume you have have sudo access +# it uses docker as default driver set -e +set -x ARG1=${1:-docker} K8_VERSION=${2:-1.21.2} + +if [ "$(uname)" == "Darwin" ]; then +EXTRA_CONFIG=--extra-config=apiserver.service-node-port-range=32700-32800 --ports=127.0.0.1:32700-32800:32700-32800 +fi + + minikube delete -minikube start --driver $ARG1 --kubernetes-version=$K8_VERSION +minikube start --driver $ARG1 --kubernetes-version=$K8_VERSION $EXTRA_CONFIG # minikube start --extra-config=apiserver.v=10 \ No newline at end of file diff --git a/src/cluster/src/start/k8.rs b/src/cluster/src/start/k8.rs index 28fcf60323..553fd1742c 100644 --- a/src/cluster/src/start/k8.rs +++ b/src/cluster/src/start/k8.rs @@ -316,6 +316,10 @@ pub struct ClusterConfig { /// ``` #[builder(default = "false")] render_checks: bool, + + /// Use proxy address for communicating with kubernetes cluster + #[builder(setter(into), default)] + proxy_addr: Option, } impl ClusterConfig { diff --git a/tests/runner/src/utils/test_meta/environment.rs b/tests/runner/src/utils/test_meta/environment.rs index 780122c895..0097466e05 100644 --- a/tests/runner/src/utils/test_meta/environment.rs +++ b/tests/runner/src/utils/test_meta/environment.rs @@ -176,6 +176,14 @@ pub struct EnvironmentSetup { /// In seconds, the maximum time a test will run before considered a fail (default: 1 hour) #[structopt(long, parse(try_from_str = parse_timeout_seconds), default_value = "3600")] pub timeout: Duration, + + /// K8: use specific image version + #[structopt(long)] + pub image_version: Option, + + /// K8: use sc address + #[structopt(long)] + pub proxy_addr: Option, } #[allow(clippy::unnecessary_wraps)]