Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.

Commit 52f708b

Browse files
authored
Merge pull request #86 from Fei-Guo/main
Install binaries for envTest
2 parents 4826e22 + 88dec80 commit 52f708b

File tree

7 files changed

+20
-9928
lines changed

7 files changed

+20
-9928
lines changed

virtualcluster/Makefile

+13-20
Original file line numberDiff line numberDiff line change
@@ -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
7788
coverage: ## combine coverage after test
7889
@mkdir -p coverage
@@ -91,35 +102,17 @@ run: generate fmt vet
91102

92103
# Install CRDs into a cluster
93104
install: 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
97108
deploy: 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.
102113
manifests: 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
125118
fmt:

virtualcluster/config/crds/cluster.x-k8s.io_clusters.yaml

-164
This file was deleted.

0 commit comments

Comments
 (0)