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

Commit

Permalink
Install binaries for envTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Guo, Fei committed Jun 3, 2021
1 parent 4826e22 commit e1f5dd3
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9,929 deletions.
34 changes: 13 additions & 21 deletions virtualcluster/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ build:
# Run tests
.PHONY: test
PWD = $(CURDIR)
test: generate fmt vet manifests
test: generate fmt vet manifests install-envtest
@mkdir -p coverage
@( for pkg in ${COVERAGE_PACKAGES}; do \
go test ${TEST_FLAGS} \
Expand All @@ -73,6 +73,16 @@ test: generate fmt vet manifests
-coverprofile=${PWD}/coverage/unit-test-pkg_vn-agent_server_test.out )
@cd ${PWD}


K8S_VERSION ?= 1.19.2
FULL_K8S_VERSION ?= Kubernetes v$(K8S_VERSION)
install-envtest:
ifneq ($(FULL_K8S_VERSION), $(shell /usr/local/kubebuilder/bin/kube-apiserver --version))
sudo mkdir -p /usr/local/kubebuilder
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"
sudo tar -C /usr/local/kubebuilder --strip-components=1 -zvxf envtest-bins.tar.gz && rm envtest-bins.tar.gz
endif

.PHONY: coverage
coverage: ## combine coverage after test
@mkdir -p coverage
Expand All @@ -91,35 +101,17 @@ run: generate fmt vet

# Install CRDs into a cluster
install: manifests
kubectl apply -f config/crds
kubectl apply -f config/crd

# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: manifests
kubectl apply -f config/crds
kubectl apply -f config/crd
kustomize build config/default | kubectl apply -f -

# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role paths="./..." output:crd:none
hack/make-rules/replace-null.sh
# To work around a known controller gen issue
# https://github.com/kubernetes-sigs/kubebuilder/issues/1544
ifeq (, $(shell which yq))
@echo "Please install yq for yaml patching. Get it from here: https://github.com/mikefarah/yq"
@exit
else
@{ \
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;\
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;\
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;\
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;\
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;\
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;\
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;\
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;\
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;\
}
endif

# Run go fmt against code
fmt:
Expand Down
164 changes: 0 additions & 164 deletions virtualcluster/config/crds/cluster.x-k8s.io_clusters.yaml

This file was deleted.

Loading

0 comments on commit e1f5dd3

Please sign in to comment.