@@ -73,6 +73,17 @@ test: generate fmt vet manifests
7373 -coverprofile=${PWD} /coverage/unit-test-pkg_vn-agent_server_test.out )
7474 @cd ${PWD}
7575
76+
77+ # run `make install-envtest` to refresh the required binaries in case the envTest fails.
78+ K8S_VERSION ?= 1.19.2
79+ FULL_K8S_VERSION ?= Kubernetes v$(K8S_VERSION )
80+ install-envtest :
81+ ifneq ($(FULL_K8S_VERSION ) , $(shell /usr/local/kubebuilder/bin/kube-apiserver --version) )
82+ sudo mkdir -p /usr/local/kubebuilder
83+ curl -sSLo envtest-bins.tar.gz "https://storage.googleapis.com/kubebuilder-tools/kubebuilder-tools-${K8S_VERSION}-$(shell go env GOOS)-$(shell go env GOARCH).tar.gz"
84+ sudo tar -C /usr/local/kubebuilder --strip-components=1 -zvxf envtest-bins.tar.gz && rm envtest-bins.tar.gz
85+ endif
86+
7687.PHONY : coverage
7788coverage : # # combine coverage after test
7889 @mkdir -p coverage
@@ -91,35 +102,17 @@ run: generate fmt vet
91102
92103# Install CRDs into a cluster
93104install : manifests
94- kubectl apply -f config/crds
105+ kubectl apply -f config/crd
95106
96107# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
97108deploy : manifests
98- kubectl apply -f config/crds
109+ kubectl apply -f config/crd
99110 kustomize build config/default | kubectl apply -f -
100111
101112# Generate manifests e.g. CRD, RBAC etc.
102113manifests : controller-gen
103114 $(CONTROLLER_GEN ) $(CRD_OPTIONS ) rbac:roleName=manager-role paths=" ./..." output:crd:none
104115 hack/make-rules/replace-null.sh
105- # To work around a known controller gen issue
106- # https://github.com/kubernetes-sigs/kubebuilder/issues/1544
107- ifeq (, $(shell which yq) )
108- @echo "Please install yq for yaml patching. Get it from here: https://github.com/mikefarah/yq"
109- @exit
110- else
111- @{ \
112- yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.apiServer.properties.statefulset.properties.spec.properties.template.properties.spec.properties.containers.items.properties.ports.items.required[1]" protocol;\
113- yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.controllerManager.properties.statefulset.properties.spec.properties.template.properties.spec.properties.containers.items.properties.ports.items.required[1]" protocol;\
114- yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.etcd.properties.statefulset.properties.spec.properties.template.properties.spec.properties.containers.items.properties.ports.items.required[1]" protocol;\
115- yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.apiServer.properties.statefulset.properties.spec.properties.template.properties.spec.properties.initContainers.items.properties.ports.items.required[1]" protocol;\
116- yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.controllerManager.properties.statefulset.properties.spec.properties.template.properties.spec.properties.initContainers.items.properties.ports.items.required[1]" protocol;\
117- yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.etcd.properties.statefulset.properties.spec.properties.template.properties.spec.properties.initContainers.items.properties.ports.items.required[1]" protocol;\
118- yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.apiServer.properties.service.properties.spec.properties.ports.items.required[1]" protocol;\
119- yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.controllerManager.properties.service.properties.spec.properties.ports.items.required[1]" protocol;\
120- yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.etcd.properties.service.properties.spec.properties.ports.items.required[1]" protocol;\
121- }
122- endif
123116
124117# Run go fmt against code
125118fmt :
0 commit comments