diff --git a/Makefile b/Makefile index 0bae549f5..afb775ef7 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,7 @@ CG_BIN_FILE=confgenerator NETFLOW_GENERATOR=nflow-generator CMD_DIR=./cmd/ FLP_CONF_FILE ?= contrib/kubernetes/flowlogs-pipeline.conf.yaml +KIND_CLUSTER_NAME ?= kind BUILD_DATE := $(shell date +%Y-%m-%d\ %H:%M) TAG_COMMIT := $(shell git rev-list --abbrev-commit --tags --max-count=1) @@ -221,24 +222,24 @@ undeploy-netflow-simulator: ## Undeploy netflow simulator .PHONY: create-kind-cluster create-kind-cluster: $(KIND) ## Create cluster - $(KIND) create cluster --config contrib/kubernetes/kind/kind.config.yaml + $(KIND) create cluster --name $(KIND_CLUSTER_NAME) --config contrib/kubernetes/kind/kind.config.yaml kubectl cluster-info --context kind-kind .PHONY: delete-kind-cluster delete-kind-cluster: $(KIND) ## Delete cluster - $(KIND) delete cluster + $(KIND) delete cluster --name $(KIND_CLUSTER_NAME) .PHONY: kind-load-image kind-load-image: ## Load image to kind ifeq ($(OCI_RUNTIME),$(shell which docker)) # This is an optimization for docker provider. "kind load docker-image" can load an image directly from docker's # local registry. For other providers (i.e. podman), we must use "kind load image-archive" instead. - $(KIND) load docker-image $(DOCKER_IMG):$(DOCKER_TAG) + $(KIND) load --name $(KIND_CLUSTER_NAME) docker-image $(DOCKER_IMG):$(DOCKER_TAG) else $(eval tmpfile="/tmp/flp.tar") -rm $(tmpfile) $(OCI_RUNTIME) save $(DOCKER_IMG):$(DOCKER_TAG) -o $(tmpfile) - $(KIND) load image-archive $(tmpfile) + $(KIND) load --name $(KIND_CLUSTER_NAME) image-archive $(tmpfile) -rm $(tmpfile) endif diff --git a/pkg/test/e2e/utils.go b/pkg/test/e2e/utils.go index c9f71760b..d01971150 100644 --- a/pkg/test/e2e/utils.go +++ b/pkg/test/e2e/utils.go @@ -91,27 +91,18 @@ func e2eDeleteKindCluster(clusterName string) env.Func { } } -// NOTE: the e2e framework uses `kind load` command that forces usage of docker (and not podman) -// ref: https://github.com/kubernetes-sigs/kind/issues/2027 func e2eBuildAndLoadImageIntoKind(dockerImg, dockerTag, clusterName string) env.Func { return func(ctx context.Context, cfg *envconf.Config) (context.Context, error) { e := gexe.New() fmt.Printf("====> building docker image - %s:%s\n", dockerImg, dockerTag) - p := e.RunProc(fmt.Sprintf(`/bin/sh -c "cd $(git rev-parse --show-toplevel); OCI_RUNTIME=docker DOCKER_IMG=%s DOCKER_TAG=%s make build-image"`, - dockerImg, dockerTag)) + p := e.RunProc(fmt.Sprintf(`/bin/sh -c "cd $(git rev-parse --show-toplevel); DOCKER_IMG=%s DOCKER_TAG=%s KIND_CLUSTER_NAME=%s make build-image kind-load-image"`, + dockerImg, dockerTag, clusterName)) if p.Err() != nil || !p.IsSuccess() || p.ExitCode() != 0 { - return nil, fmt.Errorf("failed to building docker image err=%v result=%v", p.Err(), p.Result()) - } - fmt.Printf("====> Done.\n") - fmt.Printf("====> Load image into kind \n") - p = e.RunProc(fmt.Sprintf("kind load --name %s docker-image %s:%s", clusterName, dockerImg, dockerTag)) - if p.Err() != nil || !p.IsSuccess() || p.ExitCode() != 0 { - return nil, fmt.Errorf("failed to load image into kind err=%v result=%v", p.Err(), p.Result()) + return nil, fmt.Errorf("failed to build or load docker image err=%v result=%v", p.Err(), p.Result()) } fmt.Printf("====> Done.\n") return ctx, nil } - } func e2eRecreateNamespace(name string) env.Func {