@@ -36,7 +36,7 @@ ARCH ?= amd64
3636OS ?= $(shell uname -s | tr A-Z a-z)
3737K8S_LATEST_VER ?= $(shell curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
3838export CONTROLLER_IMG ?= $(REGISTRY ) /$(IMAGE_NAME )
39- TAG ?= v1.10.0
39+ TAG ?= main
4040
4141# # Tool Binaries
4242CONTROLLER_GEN := $(TOOLS_BIN_DIR ) /controller-gen
@@ -50,7 +50,7 @@ KUBECTL := $(TOOLS_BIN_DIR)/kubectl
5050CLUSTERCTL := $(TOOLS_BIN_DIR ) /clusterctl
5151
5252GOLANGCI_LINT_VERSION := "v2.11.4"
53- CLUSTERCTL_VERSION := v1.13.1
53+ CLUSTERCTL_VERSION := v1.13.2
5454
5555KUSTOMIZE_VER := v5.8.0
5656KUSTOMIZE_BIN := kustomize
@@ -176,27 +176,50 @@ kind-test: test create-cluster fv ## Build docker image; start kind cluster; loa
176176fv : $(GINKGO ) # # Run Sveltos Controller tests using existing cluster
177177 cd test/fv; $(GINKGO ) -nodes $(NUM_NODES ) --label-filter=' FV' --v --trace --randomize-all
178178
179+ .PHONY : kind-test-namespace
180+ kind-test-namespace : test create-cluster-infra fv-namespace # # Build image; create cluster infra; deploy in random namespace and run fv
181+
182+ .PHONY : fv-namespace
183+ fv-namespace : $(GINKGO ) $(KUBECTL ) $(KUSTOMIZE ) $(ENVSUBST ) # # Deploy Sveltos in a randomly named namespace and run fv
184+ $(MAKE ) load-image
185+ $(MAKE ) deploy-crds
186+ @SVELTOS_NS=" sveltos-$$ (openssl rand -hex 4)" ; \
187+ echo " Deploying in namespace: $$ SVELTOS_NS" ; \
188+ curl -s https://raw.githubusercontent.com/projectsveltos/addon-controller/$(TAG ) /manifest/manifest.yaml | \
189+ sed -E ' s/^([[:space:]]+)(name|namespace): projectsveltos$$/\1\2: ' " $$ SVELTOS_NS" ' /' | \
190+ $(KUBECTL ) apply -f-; \
191+ $(KUBECTL ) wait --for=condition=Available deployment/addon-controller -n " $$ SVELTOS_NS" --timeout=$(TIMEOUT ) ; \
192+ $(KUSTOMIZE ) build config/default | $(ENVSUBST ) | \
193+ sed -E ' s/^([[:space:]]+)(name|namespace): projectsveltos$$/\1\2: ' " $$ SVELTOS_NS" ' /' | \
194+ $(KUBECTL ) apply -f-; \
195+ $(KUBECTL ) wait --for=condition=Available deployment/shard-controller -n " $$ SVELTOS_NS" --timeout=$(TIMEOUT ) ; \
196+ cd test/fv && SVELTOS_NAMESPACE=" $$ SVELTOS_NS" $(GINKGO ) -nodes $(NUM_NODES ) --label-filter=' FV' --v --trace --randomize-all
197+
179198.PHONY : test
180199test : manifests generate fmt vet $(SETUP_ENVTEST ) # # Run uts.
181200 KUBEBUILDER_ASSETS=" $( KUBEBUILDER_ASSETS) " go test $(shell go list ./... |grep -v test/fv |grep -v test/helpers) $(TEST_ARGS ) -coverprofile cover.out
182201
183- .PHONY : create-cluster
184- create-cluster : $(KIND ) $(CLUSTERCTL ) $(KUBECTL ) $(ENVSUBST ) # # Create a new kind cluster designed for development
202+ .PHONY : create-cluster-infra
203+ create-cluster-infra : $(KIND ) $(CLUSTERCTL ) $(KUBECTL ) $(ENVSUBST ) # # Create cluster infrastructure without deploying Sveltos
185204 $(MAKE ) create-control-cluster
186205
187206 @echo wait for capd-system pod
188207 $(KUBECTL) wait --for=condition=Available deployment/capd-controller-manager -n capd-system --timeout=$(TIMEOUT)
189- $(KUBECTL) wait --for=condition=Available deployment/capi-kubeadm-control-plane-controller-manager -n capi-kubeadm-control-plane-system --timeout=$(TIMEOUT)
208+
209+ @echo wait for capi-kubeadm-bootstrap-system pod
190210 $(KUBECTL) wait --for=condition=Available deployment/capi-kubeadm-bootstrap-controller-manager -n capi-kubeadm-bootstrap-system --timeout=$(TIMEOUT)
191211
212+ @echo wait for capi-kubeadm-control-plane-system pod
213+ $(KUBECTL) wait --for=condition=Available deployment/capi-kubeadm-control-plane-controller-manager -n capi-kubeadm-control-plane-system --timeout=$(TIMEOUT)
214+
192215 @echo "sleep allowing webhook to be ready"
193216 sleep 10
194217
195218 @echo "Create a workload cluster"
196219 $(KUBECTL) apply -f $(KIND_CLUSTER_YAML)
197220
198- @echo "Start projectsveltos event-manager "
199- $(MAKE) deploy-projectsveltos
221+ @echo "wait for cluster to be provisioned "
222+ $(KUBECTL) wait cluster $(WORKLOAD_CLUSTER_NAME) -n default --for=jsonpath='{.status.phase}'=Provisioned --timeout=$(TIMEOUT)
200223
201224 @echo "sleep allowing control plane to be ready"
202225 sleep 60
@@ -210,6 +233,11 @@ create-cluster: $(KIND) $(CLUSTERCTL) $(KUBECTL) $(ENVSUBST) ## Create a new kin
210233 @echo wait for calico pod
211234 $(KUBECTL) --kubeconfig=./test/fv/workload_kubeconfig wait --for=condition=Available deployment/calico-kube-controllers -n kube-system --timeout=$(TIMEOUT)
212235
236+ .PHONY : create-cluster
237+ create-cluster : $(KIND ) $(CLUSTERCTL ) $(KUBECTL ) $(ENVSUBST ) # # Create a new kind cluster designed for development
238+ $(MAKE ) create-cluster-infra
239+ $(MAKE ) deploy-projectsveltos
240+
213241.PHONY : delete-cluster
214242delete-cluster : $(KIND ) # # Deletes the kind cluster $(CONTROL_CLUSTER_NAME)
215243 $(KIND ) delete cluster --name $(CONTROL_CLUSTER_NAME )
@@ -301,11 +329,7 @@ create-control-cluster:
301329 @echo " Create control cluster with docker as infrastructure provider"
302330 CLUSTER_TOPOLOGY=true $(CLUSTERCTL ) init --infrastructure docker
303331
304- deploy-projectsveltos : $(KUSTOMIZE )
305- # Load projectsveltos image into cluster
306- @echo ' Load projectsveltos image into cluster'
307- $(MAKE ) load-image
308-
332+ deploy-crds :
309333 @echo ' Install libsveltos CRDs'
310334 $(KUBECTL ) apply -f https://raw.githubusercontent.com/projectsveltos/libsveltos/$(TAG ) /config/crd/bases/lib.projectsveltos.io_accessrequests.yaml
311335 $(KUBECTL ) apply -f https://raw.githubusercontent.com/projectsveltos/libsveltos/$(TAG ) /config/crd/bases/lib.projectsveltos.io_classifierreports.yaml
@@ -324,6 +348,12 @@ deploy-projectsveltos: $(KUSTOMIZE)
324348 $(KUBECTL ) apply -f https://raw.githubusercontent.com/projectsveltos/libsveltos/$(TAG ) /config/crd/bases/lib.projectsveltos.io_rolerequests.yaml
325349 $(KUBECTL ) apply -f https://raw.githubusercontent.com/projectsveltos/libsveltos/$(TAG ) /config/crd/bases/lib.projectsveltos.io_sveltosclusters.yaml
326350
351+ deploy-projectsveltos : $(KUSTOMIZE )
352+ # Load projectsveltos image into cluster
353+ @echo ' Load projectsveltos image into cluster'
354+ $(MAKE ) load-image
355+ $(MAKE ) deploy-crds
356+
327357 @echo "Deploying addon-controller"
328358 $(KUBECTL) apply -f https://raw.githubusercontent.com/projectsveltos/addon-controller/$(TAG)/manifest/manifest.yaml
329359
0 commit comments