Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split manifest generation to produce both v1/v1beta1 CRDs #4489

Merged
merged 28 commits into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
71857c5
Split manifest generation to produce both v1/v1beta1 CRDs
pebrc May 12, 2021
c39a70a
Run generate
pebrc May 12, 2021
ce7607a
Fix up make targets
pebrc May 12, 2021
1bc02f6
Integration tests need v1beta1 CRDs until we upgrade kubebuilder
pebrc May 12, 2021
6c25edb
Do not remove the complete podTemplate attribute
pebrc May 12, 2021
a0bf838
CI debugging
pebrc May 14, 2021
4547213
Move interal Helm values to globals to simplify use from dependent CR…
pebrc May 14, 2021
aa3fc0d
Upload legacy CRDs
pebrc May 14, 2021
8df2d72
Make operatorhub tool compatible with v1 and v1beta1
pebrc May 17, 2021
2c07cc6
First doc draft
pebrc May 19, 2021
cbed950
Inheriting from an empty kustomize base does not seem to work
pebrc May 19, 2021
dfc170d
Generate a CRD only manifest to facilite upgrades
pebrc May 19, 2021
2cba9b6
Fix yaml upload and adjust upgrade instructions
pebrc May 20, 2021
f85c264
Add license header
pebrc May 20, 2021
189ee86
remove debug bits
pebrc May 20, 2021
5cbde27
split manifestes by default
pebrc May 28, 2021
e777b1e
Makefile cleanup
pebrc May 28, 2021
76d9ee0
Update upgrade-test-harness to work with dedicated CRD manifest
pebrc May 31, 2021
65d131a
Add note about skipped releases
pebrc Jun 8, 2021
a3fc65b
input from review
pebrc Jun 9, 2021
fd00d6d
Apply suggestions from code review
pebrc Jun 9, 2021
362b6e1
Use release version of controller-gen
pebrc Jun 9, 2021
7425e6a
Replace references to all-in-one with new manifest names
pebrc Jun 11, 2021
20769ac
Make operatorhub tool compatible with split install manifests
pebrc Jun 11, 2021
48aece1
review input
pebrc Jun 14, 2021
4c560e7
review input
pebrc Jun 14, 2021
e930256
review input
pebrc Jun 14, 2021
cadc6ee
Apply suggestions from code review
pebrc Jun 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .ci/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

ROOT_DIR := $(CURDIR)/..
GO_MOUNT_PATH ?= /go/src/github.com/elastic/cloud-on-k8s
ALL_IN_ONE_OUTPUT_FILE ?= config/all-in-one.yaml
S3_ECK_DIR ?= s3://download.elasticsearch.org/downloads/eck
DOCKER_LOGIN ?= eckadmin

-include $(ROOT_DIR)/.env
Expand Down Expand Up @@ -110,13 +108,11 @@ license.key:
yaml-upload: VAULT_AWS_CREDS = secret/cloud-team/cloud-ci/eck-release
yaml-upload: AWS_ACCESS_KEY_ID = $(shell VAULT_TOKEN=$(VAULT_TOKEN) $(vault) read -address=$(VAULT_ADDR) -field=access-key-id $(VAULT_AWS_CREDS))
yaml-upload: AWS_SECRET_ACCESS_KEY = $(shell VAULT_TOKEN=$(VAULT_TOKEN) $(vault) read -address=$(VAULT_ADDR) -field=secret-access-key $(VAULT_AWS_CREDS))
yaml-upload: YAML_SRC = "$(GO_MOUNT_PATH)/$(ALL_IN_ONE_OUTPUT_FILE)"
yaml-upload: YAML_DST = "$(S3_ECK_DIR)/$(VERSION)/all-in-one.yaml"
yaml-upload:
ifndef VERSION
$(error VERSION not set to upload YAML to S3)
endif
@ $(MAKE) \
DOCKER_OPTS="-e AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID) -e AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY)" \
DOCKER_CMD="aws s3 ls $(YAML_DST) && echo OK: $(YAML_DST) already uploaded || aws s3 cp $(YAML_SRC) $(YAML_DST)" \
DOCKER_OPTS="-e VERSION=$(VERSION) -e AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID) -e AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY)" \
DOCKER_CMD="hack/manifest-upload.sh" \
ci-internal
2 changes: 1 addition & 1 deletion .ci/pipelines/build.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pipeline {
channel: '#cloud-k8s',
color: 'good',
message: "`${TAG_NAME}` was released \r\n" +
"https://download.elastic.co/downloads/eck/${TAG_NAME}/all-in-one.yaml was uploaded \r\n" +
"Manifests were uploaded to https://download.elastic.co/downloads/eck/${TAG_NAME}\r\n" +
"Congratulations!",
tokenCredentialId: 'cloud-ci-slack-integration-token'
)
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ test-license.json
monitoring-secrets.json

# generated from merging multiple files in the Makefile
config/all-in-one.yaml
config/operator.yaml
config/operator-legacy.yaml
config/crds.yaml
config/crds-legacy.yaml

# ignore generated configuration
config/eck.yaml
Expand Down
82 changes: 50 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ GOBIN := $(or $(shell go env GOBIN 2>/dev/null), $(shell go env GOPATH 2>/dev/nu

# find or download controller-gen
controller-gen:
ifneq ($(shell controller-gen --version 2> /dev/null), Version: v0.5.0)
@(cd /tmp; GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.5.0)
ifneq ($(shell controller-gen --version 2> /dev/null), Version: v0.6.0)
@(cd /tmp; GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.0)
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
Expand Down Expand Up @@ -85,8 +85,9 @@ dependencies:
go mod tidy -v && go mod download

# Generate code, CRDs and documentation
ALL_CRDS=config/crds/all-crds.yaml
generate: tidy generate-crds generate-config-file generate-api-docs generate-notice-file
ALL_V1_CRDS=config/crds/v1/all-crds.yaml

generate: tidy generate-crds-v1 generate-crds-v1beta1 generate-config-file generate-api-docs generate-notice-file

tidy:
go mod tidy
Expand All @@ -95,16 +96,50 @@ go-generate:
# we use this in pkg/controller/common/license
go generate -tags='$(GO_TAGS)' ./pkg/... ./cmd/...

generate-crds: go-generate controller-gen
generate-crds-v1: go-generate controller-gen
# Generate webhook manifest
# Webhook definitions exist in both pkg/apis and pkg/controller/elasticsearch/validation
$(CONTROLLER_GEN) webhook object:headerFile=./hack/boilerplate.go.txt paths=./pkg/apis/... paths=./pkg/controller/elasticsearch/validation/...
# Generate manifests e.g. CRD, RBAC etc.
$(CONTROLLER_GEN) crd:crdVersions=v1beta1 paths="./pkg/apis/..." output:crd:artifacts:config=config/crds/bases
$(CONTROLLER_GEN) crd:crdVersions=v1,generateEmbeddedObjectMeta=true paths="./pkg/apis/..." output:crd:artifacts:config=config/crds/v1/bases
# apply patches to work around some CRD generation issues, and merge them into a single file
kubectl kustomize config/crds/patches > $(ALL_CRDS)
# generate an all-in-one version including the operator manifests
$(MAKE) --no-print-directory generate-all-in-one
kubectl kustomize config/crds/v1/patches > $(ALL_V1_CRDS)
# generate a CRD only version without the operator manifests
@ ./hack/manifest-gen/manifest-gen.sh -c -g > config/crds.yaml
# generate the operator manifests
@ ./hack/manifest-gen/manifest-gen.sh -g \
--namespace=$(OPERATOR_NAMESPACE) \
--profile=global \
--set=installCRDs=false \
--set=telemetry.distributionChannel=all-in-one \
--set=image.tag=$(IMG_VERSION) \
--set=image.repository=$(BASE_IMG) \
--set=nameOverride=$(OPERATOR_NAME) \
--set=fullnameOverride=$(OPERATOR_NAME) > config/operator.yaml



generate-crds-v1beta1: go-generate controller-gen
# Generate webhook manifest
# Webhook definitions exist in both pkg/apis and pkg/controller/elasticsearch/validation
$(CONTROLLER_GEN) webhook object:headerFile=./hack/boilerplate.go.txt paths=./pkg/apis/... paths=./pkg/controller/elasticsearch/validation/...
# Generate manifests e.g. CRD, RBAC etc.
$(CONTROLLER_GEN) crd:crdVersions=v1beta1 paths="./pkg/apis/..." output:crd:artifacts:config=config/crds/v1beta1/bases
# apply patches to work around some CRD generation issues, and merge them into a single file
kubectl kustomize config/crds/v1beta1/patches > config/crds/v1beta1/all-crds.yaml
# generate a CRD only version without the operator manifests
@ ./hack/manifest-gen/manifest-gen.sh -c -g --set=global.kubeVersion=1.12.0 > config/crds-legacy.yaml
# generate the operator manifests
@ ./hack/manifest-gen/manifest-gen.sh -g \
--profile=global \
--namespace=$(OPERATOR_NAMESPACE) \
--set=global.kubeVersion=1.12.0 \
--set=installCRDs=false \
--set=telemetry.distributionChannel=all-in-one \
--set=image.tag=$(IMG_VERSION) \
--set=image.repository=$(BASE_IMG) \
--set=nameOverride=$(OPERATOR_NAME) \
--set=fullnameOverride=$(OPERATOR_NAME) > config/operator-legacy.yaml

generate-config-file:
@hack/config-extractor/extract.sh
Expand Down Expand Up @@ -141,12 +176,13 @@ unit: clean
unit-xml: clean
ECK_TEST_LOG_LEVEL=$(LOG_VERBOSITY) gotestsum --junitfile unit-tests.xml -- -cover ./pkg/... ./cmd/... $(TEST_OPTS)

# kubebuilder 2.3.1 comes with a 1.15 control plane and we rely on it for the k8s binaries
integration: GO_TAGS += integration
integration: clean generate-crds
integration: clean generate-crds-v1beta1
barkbay marked this conversation as resolved.
Show resolved Hide resolved
ECK_TEST_LOG_LEVEL=$(LOG_VERBOSITY) go test -tags='$(GO_TAGS)' ./pkg/... ./cmd/... -cover $(TEST_OPTS)

integration-xml: GO_TAGS += integration
integration-xml: clean generate-crds
integration-xml: clean generate-crds-v1beta1
ECK_TEST_LOG_LEVEL=$(LOG_VERBOSITY) gotestsum --junitfile integration-tests.xml -- -tags='$(GO_TAGS)' -cover ./pkg/... ./cmd/... $(TEST_OPTS)

lint:
Expand All @@ -162,9 +198,8 @@ upgrade-test: docker-build docker-push
#############################
## -- Run -- ##
#############################

install-crds: generate-crds
kubectl apply -f $(ALL_CRDS)
install-crds: generate-crds-v1
kubectl apply -f $(ALL_V1_CRDS)

# Run locally against the configured Kubernetes cluster, with port-forwarding enabled so that
# the operator can reach services running in the cluster through k8s port-forward feature
Expand Down Expand Up @@ -244,23 +279,6 @@ endif
apply-psp:
kubectl apply -f config/dev/elastic-psp.yaml

ALL_IN_ONE_OUTPUT_FILE=config/all-in-one.yaml

# merge all-in-one crds with operator manifests
generate-all-in-one:
@ ./hack/manifest-gen/manifest-gen.sh -g \
--namespace=$(OPERATOR_NAMESPACE) \
--set=telemetry.distributionChannel=all-in-one \
--set=image.tag=$(IMG_VERSION) \
--set=image.repository=$(BASE_IMG) \
--set=nameOverride=$(OPERATOR_NAME) \
--set=fullnameOverride=$(OPERATOR_NAME) > $(ALL_IN_ONE_OUTPUT_FILE)

# Deploy an all in one operator against the current k8s cluster
deploy-all-in-one: GO_TAGS ?= release
deploy-all-in-one: docker-build docker-push
kubectl apply -f $(ALL_IN_ONE_OUTPUT_FILE)

logs-operator:
@ kubectl --namespace=$(OPERATOR_NAMESPACE) logs -f statefulset.apps/$(OPERATOR_NAME)

Expand Down Expand Up @@ -494,7 +512,7 @@ ci-check: check-license-header lint shellcheck generate check-local-changes

ci: unit-xml integration-xml docker-build reattach-pv

setup-e2e: e2e-compile run-deployer install-crds apply-psp e2e-docker-multiarch-build
setup-e2e: e2e-compile run-deployer apply-psp e2e-docker-multiarch-build

ci-e2e: E2E_JSON := true
ci-e2e: setup-e2e e2e-run
Expand Down
Loading