forked from open-telemetry/opentelemetry-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump operator-sdk to 1.17 (open-telemetry#692)
* Bump operator-sdk to 1.14 * Remove admissionregistration.k8s.io/v1beta1 removed from 1.22, v1 was added in 1.16 * Remove crd:trivialVersions=true,preserveUnknownFields=false" that produce CRDs compatible with 1.11 Signed-off-by: Pavol Loffay <[email protected]> * Bump operator-sdk to 1.17.0 Signed-off-by: Pavol Loffay <[email protected]> * Fix Signed-off-by: Pavol Loffay <[email protected]> * remove wait Signed-off-by: Pavol Loffay <[email protected]> * fix lint Signed-off-by: Pavol Loffay <[email protected]> * Add phony Signed-off-by: Pavol Loffay <[email protected]> * install tools only to ./bin Signed-off-by: Pavol Loffay <[email protected]> * use go install Signed-off-by: Pavol Loffay <[email protected]> * guide Signed-off-by: Pavol Loffay <[email protected]> * remove ech Signed-off-by: Pavol Loffay <[email protected]> * remvoe deprecation Signed-off-by: Pavol Loffay <[email protected]> * Remove comment Signed-off-by: Pavol Loffay <[email protected]>
- Loading branch information
1 parent
7400419
commit bf0fe81
Showing
24 changed files
with
583 additions
and
357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ jobs: | |
|
||
- uses: jpkrohling/[email protected] | ||
with: | ||
operator-sdk-version: v1.13.1 | ||
operator-sdk-version: v1.17.0 | ||
|
||
- name: "basic checks" | ||
run: make ci | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ jobs: | |
|
||
- uses: jpkrohling/[email protected] | ||
with: | ||
operator-sdk-version: v1.13.1 | ||
operator-sdk-version: v1.17.0 | ||
|
||
- name: "generate release resources" | ||
run: make release-artifacts IMG_PREFIX="ghcr.io/open-telemetry/opentelemetry-operator" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ jobs: | |
|
||
- uses: jpkrohling/[email protected] | ||
with: | ||
operator-sdk-version: v1.13.1 | ||
operator-sdk-version: v1.17.0 | ||
|
||
- name: "run scorecard test" | ||
run: make scorecard-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,7 @@ BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL) | |
endif | ||
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) | ||
|
||
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion) | ||
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false,generateEmbeddedObjectMeta=true" | ||
CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true" | ||
|
||
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) | ||
ifeq (,$(shell go env GOBIN)) | ||
|
@@ -50,6 +49,11 @@ KIND_CONFIG ?= kind-$(KUBE_VERSION).yaml | |
|
||
CERTMANAGER_VERSION ?= 1.6.1 | ||
|
||
ifndef ignore-not-found | ||
ignore-not-found = false | ||
endif | ||
|
||
.PHONY: ensure-generate-is-noop | ||
ensure-generate-is-noop: VERSION=$(OPERATOR_VERSION) | ||
ensure-generate-is-noop: USER=open-telemetry | ||
ensure-generate-is-noop: set-image-controller generate bundle | ||
|
@@ -59,138 +63,173 @@ ensure-generate-is-noop: set-image-controller generate bundle | |
@git diff -s --exit-code bundle config || (echo "Build failed: the bundle, config files has been changed but the generated bundle, config files aren't up to date. Run 'make bundle' and update your PR." && git diff && exit 1) | ||
@git diff -s --exit-code docs/api.md || (echo "Build failed: the api.md file has been changed but the generated api.md file isn't up to date. Run 'make api-docs' and update your PR." && git diff && exit 1) | ||
|
||
.PHONY: all | ||
all: manager | ||
.PHONY: ci | ||
ci: test | ||
|
||
# Run tests | ||
test: generate fmt vet ensure-generate-is-noop | ||
go test ${GOTEST_OPTS} ./... | ||
# setup-envtest uses KUBEBUILDER_ASSETS which points to a directory with binaries (api-server, etcd and kubectl) | ||
.PHONY: test | ||
test: generate fmt vet ensure-generate-is-noop envtest | ||
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(KUBE_VERSION) -p path)" go test ${GOTEST_OPTS} ./... | ||
|
||
# Build manager binary | ||
.PHONY: manager | ||
manager: generate fmt vet | ||
go build -o bin/manager main.go | ||
|
||
# Run against the configured Kubernetes cluster in ~/.kube/config | ||
.PHONY: run | ||
run: generate fmt vet manifests | ||
ENABLE_WEBHOOKS=$(ENABLE_WEBHOOKS) go run -ldflags ${LD_FLAGS} ./main.go --zap-devel | ||
|
||
# Install CRDs into a cluster | ||
.PHONY: install | ||
install: manifests kustomize | ||
$(KUSTOMIZE) build config/crd | kubectl apply -f - | ||
|
||
# Uninstall CRDs from a cluster | ||
.PHONY: uninstall | ||
uninstall: manifests kustomize | ||
$(KUSTOMIZE) build config/crd | kubectl delete -f - | ||
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f - | ||
|
||
# Set the controller image parameters | ||
.PHONY: set-image-controller | ||
set-image-controller: manifests kustomize | ||
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} | ||
|
||
# Deploy controller in the current Kubernetes context, configured in ~/.kube/config | ||
.PHONY: deploy | ||
deploy: set-image-controller | ||
$(KUSTOMIZE) build config/default | kubectl apply -f - | ||
|
||
# Undeploy controller in the current Kubernetes context, configured in ~/.kube/config | ||
.PHONY: undeploy | ||
undeploy: set-image-controller | ||
$(KUSTOMIZE) build config/default | kubectl delete -f - | ||
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f - | ||
|
||
# Generates the released manifests | ||
.PHONY: release-artifacts | ||
release-artifacts: set-image-controller | ||
mkdir -p dist | ||
$(KUSTOMIZE) build config/default -o dist/opentelemetry-operator.yaml | ||
|
||
# Generate manifests e.g. CRD, RBAC etc. | ||
.PHONY: manifests | ||
manifests: controller-gen | ||
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases | ||
|
||
# Run go fmt against code | ||
.PHONY: fmt | ||
fmt: | ||
go fmt ./... | ||
|
||
# Run go vet against code | ||
.PHONY: vet | ||
vet: | ||
go vet ./... | ||
|
||
# Run go lint against code | ||
.PHONY: lint | ||
lint: | ||
golangci-lint run | ||
|
||
# Generate code | ||
.PHONY: generate | ||
generate: controller-gen api-docs | ||
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." | ||
|
||
# end-to-tests | ||
.PHONY: e2e | ||
e2e: | ||
$(KUTTL) test | ||
|
||
.PHONY: prepare-e2e | ||
prepare-e2e: kuttl set-test-image-vars set-image-controller container start-kind | ||
mkdir -p tests/_build/crds tests/_build/manifests | ||
$(KUSTOMIZE) build config/default -o tests/_build/manifests/01-opentelemetry-operator.yaml | ||
$(KUSTOMIZE) build config/crd -o tests/_build/crds/ | ||
|
||
.PHONY: scorecard-tests | ||
scorecard-tests: | ||
$(OPERATOR_SDK) scorecard -w=5m bundle || (echo "scorecard test failed" && exit 1) | ||
|
||
.PHONY: set-test-image-vars | ||
set-test-image-vars: | ||
$(eval IMG=local/opentelemetry-operator:e2e) | ||
|
||
# Build the container image, used only for local dev purposes | ||
.PHONY: container | ||
container: | ||
docker build -t ${IMG} --build-arg VERSION_PKG=${VERSION_PKG} --build-arg VERSION=${VERSION} --build-arg VERSION_DATE=${VERSION_DATE} --build-arg OTELCOL_VERSION=${OTELCOL_VERSION} --build-arg TARGETALLOCATOR_VERSION=${TARGETALLOCATOR_VERSION} --build-arg AUTO_INSTRUMENTATION_JAVA_VERSION=${AUTO_INSTRUMENTATION_JAVA_VERSION} --build-arg AUTO_INSTRUMENTATION_NODEJS_VERSION=${AUTO_INSTRUMENTATION_NODEJS_VERSION} --build-arg AUTO_INSTRUMENTATION_PYTHON_VERSION=${AUTO_INSTRUMENTATION_PYTHON_VERSION} . | ||
|
||
# Push the container image, used only for local dev purposes | ||
.PHONY: container-push | ||
container-push: | ||
docker push ${IMG} | ||
|
||
.PHONY: start-kind | ||
start-kind: | ||
kind create cluster --config $(KIND_CONFIG) | ||
kind load docker-image local/opentelemetry-operator:e2e | ||
|
||
.PHONY: cert-manager | ||
cert-manager: cmctl | ||
# Consider using cmctl to install the cert-manager once install command is not experimental | ||
kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v${CERTMANAGER_VERSION}/cert-manager.yaml | ||
cmctl check api --wait=5m | ||
$(CMCTL) check api --wait=5m | ||
|
||
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
CMCTL = $(shell pwd)/bin/cmctl | ||
.PHONY: cmctl | ||
cmctl: | ||
ifeq (, $(shell which cmctl)) | ||
@{ \ | ||
curl -L -o /tmp/cmctl.tar.gz https://github.com/jetstack/cert-manager/releases/download/v$(CERTMANAGER_VERSION)/cmctl-`go env GOOS`-`go env GOARCH`.tar.gz ;\ | ||
cd /tmp ;\ | ||
tar xzf cmctl.tar.gz ;\ | ||
mv cmctl $(GOBIN) ;\ | ||
} | ||
CTL=$(GOBIN)/cmctl | ||
else | ||
CTL=$(shell which cmctl) | ||
endif | ||
|
||
# find or download controller-gen | ||
# download controller-gen if necessary | ||
controller-gen: | ||
ifeq (, $(shell which controller-gen)) | ||
@{ \ | ||
go install sigs.k8s.io/controller-tools/cmd/[email protected] ;\ | ||
} | ||
CONTROLLER_GEN=$(GOBIN)/controller-gen | ||
else | ||
CONTROLLER_GEN=$(shell which controller-gen) | ||
endif | ||
|
||
kustomize: | ||
ifeq (, $(shell which kustomize)) | ||
@{ \ | ||
set -e ;\ | ||
echo "" ;\ | ||
echo "ERROR: kustomize not found." ;\ | ||
echo "Please check https://kubectl.docs.kubernetes.io/installation/kustomize/ for installation instructions and try again." ;\ | ||
echo "" ;\ | ||
exit 1 ;\ | ||
TMP_DIR=$$(mktemp -d) ;\ | ||
curl -L -o $$TMP_DIR/cmctl.tar.gz https://github.com/jetstack/cert-manager/releases/download/v$(CERTMANAGER_VERSION)/cmctl-`go env GOOS`-`go env GOARCH`.tar.gz ;\ | ||
tar xzf $$TMP_DIR/cmctl.tar.gz -C $$TMP_DIR ;\ | ||
[ -d bin ] || mkdir bin ;\ | ||
mv $$TMP_DIR/cmctl $(CMCTL) ;\ | ||
rm -rf $$TMP_DIR ;\ | ||
} | ||
KUSTOMIZE=$(GOBIN)/kustomize | ||
else | ||
KUSTOMIZE=$(shell which kustomize) | ||
endif | ||
|
||
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen | ||
.PHONY: controller-gen | ||
controller-gen: ## Download controller-gen locally if necessary. | ||
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,v0.8.0) | ||
|
||
KUSTOMIZE = $(shell pwd)/bin/kustomize | ||
.PHONY: kustomize | ||
kustomize: ## Download kustomize locally if necessary. | ||
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v3,v3.8.7) | ||
|
||
ENVTEST = $(shell pwd)/bin/setup-envtest | ||
.PHONY: envtest | ||
envtest: ## Download envtest-setup locally if necessary. | ||
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest,latest) | ||
|
||
CRDOC = $(shell pwd)/bin/crdoc | ||
.PHONY: crdoc | ||
crdoc: ## Download crdoc locally if necessary. | ||
$(call go-get-tool,$(CRDOC), fybrik.io/crdoc,v0.5.2) | ||
|
||
# go-get-tool will 'go get' any package $2 and install it to $1. | ||
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
define go-get-tool | ||
@[ -f $(1) ] || { \ | ||
set -e ;\ | ||
TMP_DIR=$$(mktemp -d) ;\ | ||
cd $$TMP_DIR ;\ | ||
go mod init tmp ;\ | ||
echo "Downloading $(2)" ;\ | ||
go get -d $(2)@$(3) ;\ | ||
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\ | ||
rm -rf $$TMP_DIR ;\ | ||
} | ||
endef | ||
|
||
.PHONY: kuttl | ||
kuttl: | ||
ifeq (, $(shell which kubectl-kuttl)) | ||
echo ${PATH} | ||
|
@@ -209,6 +248,7 @@ else | |
KUTTL=$(shell which kubectl-kuttl) | ||
endif | ||
|
||
.PHONY: kind | ||
kind: | ||
ifeq (, $(shell which kind)) | ||
@{ \ | ||
|
@@ -223,6 +263,7 @@ else | |
KIND=$(shell which kind) | ||
endif | ||
|
||
.PHONY: operator-sdk | ||
operator-sdk: | ||
ifeq (, $(shell which operator-sdk)) | ||
@{ \ | ||
|
@@ -238,41 +279,29 @@ OPERATOR_SDK=$(shell which operator-sdk) | |
endif | ||
|
||
# Generate bundle manifests and metadata, then validate generated files. | ||
.PHONY: bundle | ||
bundle: kustomize operator-sdk manifests set-image-controller | ||
$(OPERATOR_SDK) generate kustomize manifests -q | ||
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) | ||
$(OPERATOR_SDK) bundle validate ./bundle | ||
|
||
# Build the bundle image, used only for local dev purposes | ||
.PHONY: bundle-build | ||
bundle-build: | ||
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) . | ||
|
||
.PHONY: bundle-push | ||
bundle-push: | ||
docker push $(BUNDLE_IMG) | ||
|
||
.PHONY: tools | ||
tools: ginkgo kustomize controller-gen operator-sdk | ||
|
||
|
||
.PHONY: api-docs | ||
api-docs: crdoc kustomize | ||
@{ \ | ||
set -e ;\ | ||
TMP_DIR=$$(mktemp -d) ; \ | ||
$(KUSTOMIZE) build config/crd -o $$TMP_DIR/crd-output.yaml ;\ | ||
$(API_REF_GEN) crdoc --resources $$TMP_DIR/crd-output.yaml --output docs/api.md ;\ | ||
$(CRDOC) --resources $$TMP_DIR/crd-output.yaml --output docs/api.md ;\ | ||
} | ||
|
||
# Find or download crdoc | ||
crdoc: | ||
ifeq (, $(shell which crdoc)) | ||
@{ \ | ||
set -e ;\ | ||
API_REF_GEN_TMP_DIR=$$(mktemp -d) ;\ | ||
cd $$API_REF_GEN_TMP_DIR ;\ | ||
go mod init tmp ;\ | ||
go get fybrik.io/[email protected] ;\ | ||
rm -rf $$API_REF_GEN_TMP_DIR ;\ | ||
} | ||
API_REF_GEN=$(GOBIN)/crdoc | ||
else | ||
API_REF_GEN=$(shell which crdoc) | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.