@@ -58,6 +58,7 @@ BIN_DIR := bin
5858BUILD_DIR := .build
5959TEST_DIR := test
6060VCSIM_DIR := test/infrastructure/vcsim
61+ NETOP_DIR := test/infrastructure/net-operator
6162TOOLS_DIR := hack/tools
6263TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR ) /$(BIN_DIR ) )
6364FLAVOR_DIR := $(ROOT_DIR ) /templates
@@ -223,9 +224,15 @@ VM_OPERATOR_IMAGE_NAME ?= extra/vm-operator
223224VM_OPERATOR_CONTROLLER_IMG ?= $(STAGING_REGISTRY ) /$(VM_OPERATOR_IMAGE_NAME )
224225VM_OPERATOR_DIR := test/infrastructure/vm-operator
225226VM_OPERATOR_TMP_DIR ?= vm-operator.tmp
226- VM_OPERATOR_VERSION ?= v1.8.1
227+ # note: this is the commit from 1.8.6 tag
228+ VM_OPERATOR_COMMIT ?= de75746a9505ef3161172d99b735d6593c54f0c5
229+ VM_OPERATOR_VERSION ?= v1.8.6-0-gde75746a
227230VM_OPERATOR_ALL_ARCH = amd64 arm64
228231
232+ # net operator
233+ NET_OPERATOR_IMAGE_NAME ?= cluster-api-net-operator
234+ NET_OPERATOR_IMG ?= $(STAGING_REGISTRY ) /$(NET_OPERATOR_IMAGE_NAME )
235+
229236# It is set by Prow GIT_TAG, a git-based tag of the form vYYYYMMDD-hash, e.g., v20210120-v0.3.10-308-gc61521971
230237
231238TAG ?= dev
@@ -255,6 +262,7 @@ VCSIM_CRD_ROOT ?= $(VCSIM_DIR)/config/crd/bases
255262WEBHOOK_ROOT ?= $(MANIFEST_ROOT ) /webhook
256263RBAC_ROOT ?= $(MANIFEST_ROOT ) /rbac
257264VCSIM_RBAC_ROOT ?= $(VCSIM_DIR ) /config/rbac
265+ NETOP_RBAC_ROOT ?= $(NETOP_DIR ) /config/rbac
258266VERSION ?= $(shell cat clusterctl-settings.json | jq .config.nextVersion -r)
259267OVERRIDES_DIR := $(HOME ) /.cluster-api/overrides/infrastructure-vsphere/$(VERSION )
260268
@@ -294,16 +302,21 @@ generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
294302 paths=./apis/vmware/v1beta1 \
295303 crd:crdVersions=v1 \
296304 output:crd:dir=$(SUPERVISOR_CRD_ROOT )
297- # vm-operator crds are loaded to be used for integration tests .
305+ # vm-operator crds are used for test .
298306 $(CONTROLLER_GEN ) \
299307 paths=github.com/vmware-tanzu/vm-operator/api/v1alpha1/... \
300308 crd:crdVersions=v1 \
301309 output:crd:dir=$(VMOP_CRD_ROOT )
310+ # net-operator is used for tests
311+ $(CONTROLLER_GEN ) \
312+ paths=./$(NETOP_DIR ) /controllers/... \
313+ output:rbac:dir =$(NETOP_RBAC_ROOT ) \
314+ rbac:roleName=manager-role
302315 # vcsim crds are used for tests.
303316 $(CONTROLLER_GEN) \
304- paths=./$(VCSIM_DIR)/api/v1alpha1 \
305- crd :crdVersions=v1 \
306- output :crd:dir=$(VCSIM_CRD_ROOT )
317+ paths=./$(VCSIM_DIR)/api/v1alpha1 \
318+ crd:crdVersions=v1 \
319+ output:crd:dir=$(VCSIM_CRD_ROOT)
307320 $(CONTROLLER_GEN) \
308321 paths=./$(VCSIM_DIR)/ \
309322 paths=./$(VCSIM_DIR)/controllers/... \
@@ -317,8 +330,8 @@ generate-go-deepcopy: $(CONTROLLER_GEN) ## Generate deepcopy go code for core
317330 object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \
318331 paths=./apis/...
319332 $(CONTROLLER_GEN ) \
320- object :headerFile=./hack/boilerplate/boilerplate.generatego.txt \
321- paths=./$(VCSIM_DIR)/api/...
333+ object :headerFile=./hack/boilerplate/boilerplate.generatego.txt \
334+ paths=./$(VCSIM_DIR)/api/...
322335
323336.PHONY : generate-go-conversions
324337generate-go-conversions : $(CONTROLLER_GEN ) $(CONVERSION_GEN ) # # Runs Go related generate targets
@@ -539,6 +552,15 @@ docker-build-vcsim: docker-pull-prerequisites ## Build the docker image for vcsi
539552 $(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./$(VCSIM_DIR)/config/default/manager_pull_policy.yaml"; \
540553 fi
541554
555+ .PHONY : docker-build-net-operator
556+ docker-build-net-operator : docker-pull-prerequisites # # Build the docker image for net-operator controller manager
557+ # # reads Dockerfile from stdin to avoid an incorrectly cached Dockerfile (https://github.com/moby/buildkit/issues/1368)
558+ cat $(NETOP_DIR)/Dockerfile | DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg goproxy=$(GOPROXY) --build-arg ARCH=$(ARCH) --build-arg ldflags="$(LDFLAGS)" . -t $(NET_OPERATOR_IMG)-$(ARCH):$(TAG) --file -
559+ @if [ "${DOCKER_BUILD_MODIFY_MANIFESTS}" = "true" ]; then \
560+ $(MAKE) set-manifest-image MANIFEST_IMG=$(NET_OPERATOR_IMG)-$(ARCH) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./$(NETOP_DIR)/config/default/manager_image_patch.yaml"; \
561+ $(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./$(NETOP_DIR)/config/default/manager_pull_policy.yaml"; \
562+ fi
563+
542564# # --------------------------------------
543565# # Testing
544566# # --------------------------------------
@@ -586,6 +608,7 @@ e2e-images: ## Build the e2e manager image
586608 # also the same settings must exist in e2e.sh
587609 $(MAKE) REGISTRY=gcr.io/k8s-staging-capi-vsphere PULL_POLICY=IfNotPresent TAG=dev docker-build
588610 $(MAKE) REGISTRY=gcr.io/k8s-staging-capi-vsphere PULL_POLICY=IfNotPresent TAG=dev docker-build-vcsim
611+ $(MAKE) REGISTRY=gcr.io/k8s-staging-capi-vsphere PULL_POLICY=IfNotPresent TAG=dev docker-build-net-operator
589612
590613.PHONY : e2e
591614e2e : e2e-images generate-e2e-templates
@@ -785,13 +808,15 @@ vm-operator-checkout:
785808 @if [ -z " ${VM_OPERATOR_VERSION} " ]; then echo " VM_OPERATOR_VERSION is not set" ; exit 1; fi
786809 @if [ -d " $( VM_OPERATOR_TMP_DIR) " ]; then \
787810 echo " $( VM_OPERATOR_TMP_DIR) exists, skipping clone" ; \
788- cd " $( VM_OPERATOR_TMP_DIR) " ; \
789- if [ " $$ (git describe --match " v[0-9]* " )" != " $( VM_OPERATOR_VERSION) " ]; then \
790- echo " ERROR: checked out version $$ (git describe --match " v[0-9]* " ) does not match expected version $( VM_OPERATOR_VERSION) " ; \
791- exit 1; \
792- fi \
793811 else \
794- git clone --depth 1 --branch " $( VM_OPERATOR_VERSION) " " https://github.com/vmware-tanzu/vm-operator.git" " $( VM_OPERATOR_TMP_DIR) " ; \
812+ git clone " https://github.com/vmware-tanzu/vm-operator.git" " $( VM_OPERATOR_TMP_DIR) " ; \
813+ cd " $( VM_OPERATOR_TMP_DIR) " ; \
814+ git checkout " $( VM_OPERATOR_COMMIT) " ; \
815+ fi
816+ @cd " $( ROOT_DIR) /$( VM_OPERATOR_TMP_DIR) " ; \
817+ if [ " $$ (git describe --dirty 2> /dev/null)" != " $( VM_OPERATOR_VERSION) " ]; then \
818+ echo " ERROR: checked out version $$ (git describe --dirty 2> /dev/null) does not match expected version $( VM_OPERATOR_VERSION) " ; \
819+ exit 1; \
795820 fi
796821
797822.PHONY : vm-operator-manifest-build
0 commit comments