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

release: 0.9.0 #68

Merged
merged 6 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/release-catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
run: make catalog-push

- name: Build and push the current catalog container image as latest
run: make catalog-retag-latest
run: make catalog-push-latest
8 changes: 4 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ jobs:
- name: Build and push bundle container image
run: make bundle-push

- id: bundle-image-name
- id: bundle-image
name: Retrieves the bundle image name
run: echo "BUNDLE_IMAGE=$(make -s bundle-image-name)" >> $GITHUB_OUTPUT
run: echo "BUNDLE_IMAGE=$(make -s bundle-image)" >> $GITHUB_OUTPUT

- name: Update catalog files with the new bundle
run: make catalog-update
run: make catalog

- name: Create a new draft-release in github
run: gh release create "${{ env.RELEASE }}" --draft --title "${{ env.RELEASE }}" --generate-notes
Expand All @@ -79,7 +79,7 @@ jobs:
CATALOG_RELEASE_PR_BODY: |
This PR updates the catalog inventory files with the new bundle [${{ needs.check.outputs.stable-release }}](https://github.com/${GITHUB_REPOSITORY}/releases/tag/${{ needs.check.outputs.stable-release }}).

[${{ steps.bundle-image-name.outputs.BUNDLE_IMAGE }}](https://${{ steps.bundle-image-name.outputs.BUNDLE_IMAGE }})
[${{ steps.bundle-image.outputs.BUNDLE_IMAGE }}](https://${{ steps.bundle-image.outputs.BUNDLE_IMAGE }})

Please review and merge this PR to build and release the new catalog.

Expand Down
241 changes: 123 additions & 118 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# To re-generate a bundle for another specific version without changing the standard setup, you can:
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
VERSION ?= 0.8.2
VERSION ?= 0.9.0

# CHANNELS define the bundle channels used in the bundle.
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
Expand Down Expand Up @@ -78,10 +78,6 @@ help: ## Display this help.

##@ Build

.PHONY: run
run: ansible-operator ## Run against the configured Kubernetes cluster in ~/.kube/config
ANSIBLE_ROLES_PATH="$(ANSIBLE_ROLES_PATH):$(shell pwd)/roles" $(ANSIBLE_OPERATOR) run

.PHONY: container-build
container-build: ## Build container with the manager.
${CONTAINER_RUNTIME} buildx build \
Expand All @@ -94,31 +90,27 @@ container-push: ## Push container image with the manager.
--platform linux/arm64,linux/amd64 \
--tag $(IMG) --file $(CONTAINER_FILE) $(CONTAINER_CTX)

.PHONY: container-image-name
container-image-name: ## Outputs the container image
.PHONY: container-image
container-image: ## Outputs the container image name and tag.
@echo $(IMG)

##@ Deployment

.PHONY: install
install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl apply -f -

.PHONY: uninstall
uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl delete -f -

.PHONY: deploy
deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/manual | kubectl apply -f -
##@ Dependencies

.PHONY: undeploy
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/manual | kubectl delete -f -

OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
ARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')
.PHONY: ansible-operator
ANSIBLE_OPERATOR = $(shell pwd)/bin/ansible-operator
ansible-operator: ## Download ansible-operator locally if necessary, preferring the $(pwd)/bin path over global if both exist.
ifeq (,$(wildcard $(ANSIBLE_OPERATOR)))
ifeq (,$(shell which ansible-operator 2>/dev/null))
@{ \
set -e ;\
mkdir -p $(dir $(ANSIBLE_OPERATOR)) ;\
curl -sSLo $(ANSIBLE_OPERATOR) https://github.com/operator-framework/operator-sdk/releases/download/v1.24.0/ansible-operator_$(OS)_$(ARCH) ;\
chmod +x $(ANSIBLE_OPERATOR) ;\
}
else
ANSIBLE_OPERATOR = $(shell which ansible-operator)
endif
endif

.PHONY: kustomize
KUSTOMIZE = $(shell pwd)/bin/kustomize
Expand All @@ -136,22 +128,83 @@ KUSTOMIZE = $(shell which kustomize)
endif
endif

.PHONY: ansible-operator
ANSIBLE_OPERATOR = $(shell pwd)/bin/ansible-operator
ansible-operator: ## Download ansible-operator locally if necessary, preferring the $(pwd)/bin path over global if both exist.
ifeq (,$(wildcard $(ANSIBLE_OPERATOR)))
ifeq (,$(shell which ansible-operator 2>/dev/null))
.PHONY: opm
OPM = ./bin/opm
opm: ## Download opm locally if necessary.
ifeq (,$(wildcard $(OPM)))
ifeq (,$(shell which opm 2>/dev/null))
@{ \
set -e ;\
mkdir -p $(dir $(ANSIBLE_OPERATOR)) ;\
curl -sSLo $(ANSIBLE_OPERATOR) https://github.com/operator-framework/operator-sdk/releases/download/v1.24.0/ansible-operator_$(OS)_$(ARCH) ;\
chmod +x $(ANSIBLE_OPERATOR) ;\
mkdir -p $(dir $(OPM)) ;\
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0/$(OS)-$(ARCH)-opm ;\
chmod +x $(OPM) ;\
}
else
ANSIBLE_OPERATOR = $(shell which ansible-operator)
OPM = $(shell which opm)
endif
endif

#############################################
#### Custom Targets with extra binaries #####
#############################################

.PHONY: operator-sdk
OPERATOR_SDK_RELEASE = v1.24.0
OPERATOR_SDK = $(shell pwd)/bin/operator-sdk-$(OPERATOR_SDK_RELEASE)
OPERATOR_SDK_DL_URL = https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_RELEASE)/operator-sdk_$(OS)_$(ARCH)
operator-sdk: ## Download operator-sdk binary if necessary.
@if [ ! -f $(OPERATOR_SDK) ]; then\
mkdir -p $(shell pwd)/bin;\
curl -sL -o $(OPERATOR_SDK) $(OPERATOR_SDK_DL_URL);\
chmod +x $(OPERATOR_SDK);\
fi

## Download kind locally if necessary.
KIND_RELEASE = v0.11.1
KIND = $(shell pwd)/bin/kind-$(KIND_RELEASE)
KIND_DL_URL = https://github.com/kubernetes-sigs/kind/releases/download/$(KIND_RELEASE)/kind-$(OS)-$(ARCH)
$(KIND):
mkdir -p $(shell pwd)/bin
curl -sL -o $(KIND) $(KIND_DL_URL)
chmod +x $(KIND)

## Download kuttl locally if necessary for e2e tests.
KUTTL_RELEASE = 0.9.0
KUTTL = $(shell pwd)/bin/kuttl-v$(KUTTL_RELEASE)
KUTTL_DL_URL = https://github.com/kudobuilder/kuttl/releases/download/v$(KUTTL_RELEASE)/kubectl-kuttl_$(KUTTL_RELEASE)_$(OS)_x86_64
$(KUTTL):
mkdir -p $(shell pwd)/bin
curl -sL -o $(KUTTL) $(KUTTL_DL_URL)
chmod +x $(KUTTL)

##@ Deployment

.PHONY: run
run: ansible-operator ## Run against the configured Kubernetes cluster in ~/.kube/config.
ANSIBLE_ROLES_PATH="$(ANSIBLE_ROLES_PATH):$(shell pwd)/roles" $(ANSIBLE_OPERATOR) run

.PHONY: install
install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl apply -f -

.PHONY: uninstall
uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl delete -f -

.PHONY: deploy
deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/manual | kubectl apply -f -

.PHONY: undeploy
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/manual | kubectl delete -f -

OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
ARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')

##@ Bundle

.PHONY: bundle
bundle: operator-sdk kustomize ## Generate bundle manifests and metadata, then validate generated files.
$(OPERATOR_SDK) generate kustomize manifests -q
Expand All @@ -169,30 +222,15 @@ bundle-push: ## Push the bundle image.
$(MAKE) container-push \
IMG=$(BUNDLE_IMG) CONTAINER_FILE=$(BUNDLE_CONTAINER_FILE)

bundle-image-name: ## Outputs the bundle image name
@$(MAKE) container-image-name IMG=$(BUNDLE_IMG)

.PHONY: opm
OPM = ./bin/opm
opm: ## Download opm locally if necessary.
ifeq (,$(wildcard $(OPM)))
ifeq (,$(shell which opm 2>/dev/null))
@{ \
set -e ;\
mkdir -p $(dir $(OPM)) ;\
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0/$(OS)-$(ARCH)-opm ;\
chmod +x $(OPM) ;\
}
else
OPM = $(shell which opm)
endif
endif

bundle-image: ## Outputs the bundle image name.
@$(MAKE) container-image IMG=$(BUNDLE_IMG)

# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0).
# These images MUST exist in a registry and be pull-able.
BUNDLE_IMGS ?= $(BUNDLE_IMG)

##@ Catalog

# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:v$(VERSION)

Expand All @@ -213,129 +251,96 @@ ifneq ($(origin CATALOG_BASE_IMG), undefined)
FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG)
endif

catalog-render: opm ## Render the clusterserviceversion yaml
.PHONY: catalog
catalog: opm catalog-add-bundle catalog-validate ## Update and validate the catalog with the current bundle.

catalog-render-bundle: opm # Render the current clusterserviceversion yaml from the bundle container into the catalog.
$(OPM) render $(BUNDLE_IMGS) -oyaml > catalog/prometheus-exporter-operator/objects/prometheus-exporter-operator.v$(VERSION).clusterserviceversion.yaml

catalog-add-entry: ## Add catalog entry if missing
catalog-add-entry: # Adds a catalog entry if missing
grep -Eq 'name: prometheus-exporter-operator\.v$(VERSION)$$' $(CATALOG_CHANNEL_FILE) || \
yq -i '.entries += {"name": "prometheus-exporter-operator.v$(VERSION)","replaces":"$(shell yq '.entries[-1].name' $(CATALOG_CHANNEL_FILE))"}' $(CATALOG_CHANNEL_FILE)

.PHONY: catalog-add-bundle-to-alpha
catalog-add-bundle-to-alpha: opm catalog-render ## Adds the alpha bundle to a file based catalog
catalog-add-bundle-to-alpha: opm catalog-render-bundle # Adds the alpha bundle to a file based catalog
$(MAKE) catalog-add-entry CATALOG_CHANNEL_FILE=catalog/prometheus-exporter-operator/alpha-channel.yaml

.PHONY: catalog-add-bundle-to-stable
catalog-add-bundle-to-stable: opm catalog-render catalog-add-bundle-to-alpha ## Adds a bundle to a file based catalog
catalog-add-bundle-to-stable: opm catalog-render-bundle catalog-add-bundle-to-alpha # Adds a bundle to a file based catalog
$(MAKE) catalog-add-entry CATALOG_CHANNEL_FILE=catalog/prometheus-exporter-operator/stable-channel.yaml

.PHONY: catalog-add-bundle
catalog-add-bundle: opm catalog-render ## Adds a bundle to a file based catalog
catalog-add-bundle: opm catalog-render-bundle # Adds a bundle to a file based catalog
if echo $(VERSION) | grep -q 'alpha'; \
then $(MAKE) catalog-add-bundle-to-alpha; \
else $(MAKE) catalog-add-bundle-to-stable; \
fi

# Validate the catalog.
.PHONY: catalog-validate
catalog-validate: ## Push a catalog image.
catalog-validate: # Validate the catalog files.
$(OPM) validate catalog/prometheus-exporter-operator

.PHONY: catalog-update
catalog-update: opm catalog-add-bundle catalog-validate ## Update and generate new release catalog files

catalog-build: opm catalog-validate ## Build the bundle image.
catalog-build: opm catalog-validate ## Build the catalog image.
$(MAKE) container-build \
IMG=$(CATALOG_IMG) CONTAINER_FILE=$(CATALOG_CONTAINER_FILE) CONTAINER_CTX=$(CATALOG_CONTAINER_CTX)

# Push the catalog image.
.PHONY: catalog-push
catalog-push: opm catalog-validate ## Push a catalog image.
$(MAKE) container-push\
IMG=$(CATALOG_IMG) CONTAINER_FILE=$(CATALOG_CONTAINER_FILE) CONTAINER_CTX=$(CATALOG_CONTAINER_CTX)

#############################################
#### Custom Targets with extra binaries #####
#############################################

# Download operator-sdk binary if necessary
.PHONY: operator-sdk
OPERATOR_SDK_RELEASE = v1.24.0
OPERATOR_SDK = $(shell pwd)/bin/operator-sdk-$(OPERATOR_SDK_RELEASE)
OPERATOR_SDK_DL_URL = https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_RELEASE)/operator-sdk_$(OS)_$(ARCH)
operator-sdk:
@if [ ! -f $(OPERATOR_SDK) ]; then\
mkdir -p $(shell pwd)/bin;\
curl -sL -o $(OPERATOR_SDK) $(OPERATOR_SDK_DL_URL);\
chmod +x $(OPERATOR_SDK);\
fi

# Download kind locally if necessary
KIND_RELEASE = v0.11.1
KIND = $(shell pwd)/bin/kind-$(KIND_RELEASE)
KIND_DL_URL = https://github.com/kubernetes-sigs/kind/releases/download/$(KIND_RELEASE)/kind-$(OS)-$(ARCH)
$(KIND):
mkdir -p $(shell pwd)/bin
curl -sL -o $(KIND) $(KIND_DL_URL)
chmod +x $(KIND)
catalog-image: ## Outputs the catalog image name.
@$(MAKE) container-image IMG=$(CATALOG_IMG)

# Download kuttl locally if necessary for e2e tests
KUTTL_RELEASE = 0.9.0
KUTTL = $(shell pwd)/bin/kuttl-v$(KUTTL_RELEASE)
KUTTL_DL_URL = https://github.com/kudobuilder/kuttl/releases/download/v$(KUTTL_RELEASE)/kubectl-kuttl_$(KUTTL_RELEASE)_$(OS)_x86_64
$(KUTTL):
mkdir -p $(shell pwd)/bin
curl -sL -o $(KUTTL) $(KUTTL_DL_URL)
chmod +x $(KUTTL)
catalog-push-latest: ## Push the catalog with the `latest` image tag.
$(MAKE) container-push \
IMG=$(CATALOG_BASE_IMG) CONTAINER_FILE=$(CATALOG_CONTAINER_FILE) CONTAINER_CTX=$(CATALOG_CONTAINER_CTX)

####################################################
#### Custom Targets to publish release catalog #####
##### Custom Targets to release a new version ######
####################################################
##@ Release Catalog
##@ Release

prepare-release:
get-new-release:
@hack/new-release.sh v$(VERSION)

prepare-release: ## Prepare bundle release files.
if echo $(VERSION) | grep -q 'alpha'; \
then $(MAKE) prepare-alpha-release; \
else $(MAKE) prepare-stable-release; \
fi

prepare-alpha-release: bundle ## Prepare alpha release
prepare-alpha-release: bundle # Prepare alpha release.

prepare-stable-release: bundle ## Prepare stable release
prepare-stable-release: bundle # Prepare stable release.
slopezz marked this conversation as resolved.
Show resolved Hide resolved
$(MAKE) bundle CHANNELS=alpha,stable DEFAULT_CHANNEL=alpha

catalog-retag-latest:
$(MAKE) container-push \
IMG=$(CATALOG_BASE_IMG) CONTAINER_FILE=$(CATALOG_CONTAINER_FILE) CONTAINER_CTX=$(CATALOG_CONTAINER_CTX)

bundle-publish: prepare-release bundle-push ## Publish new bundle

catalog-publish: catalog-add-bundle catalog-push catalog-retag-latest ## Builds and pushes the catalog image
bundle-publish: prepare-release bundle-push ## Publish new bundle.

release-publish: container-push bundle-publish catalog-publish ## Publish a new stable release (operator, catalog and bundle)
catalog-publish: catalog-add-bundle catalog-push catalog-push-latest ## Build and push the catalog image.

get-new-release:
@hack/new-release.sh v$(VERSION)
release-publish: container-push bundle-publish catalog-publish ## Publish a new release (operator, catalog and bundle).

###################################################
#### Custom Targets to manually test with Kind ####
###################################################
##@ Testing

kind-create: export KUBECONFIG = ${PWD}/kubeconfig
kind-create: $(KIND) ## Creates a k8s kind cluster
kind-create: $(KIND) ## Creates a k8s kind cluster.
$(KIND) create cluster --wait 5m || true

kind-delete: $(KIND) ## Deletes the k8s kind cluster
kind-delete: $(KIND) ## Deletes the k8s kind cluster.
$(KIND) delete cluster

kind-deploy: export KUBECONFIG = ${PWD}/kubeconfig
kind-deploy: kustomize $(KIND) ## Deploys the operator in the k8s kind cluster
kind-deploy: kustomize $(KIND) ## Deploys the operator in the k8s kind cluster.
${CONTAINER_RUNTIME} build --tag $(IMG) \
--file $(CONTAINER_FILE) $(CONTAINER_CTX)
$(KIND) load docker-image $(IMG)
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/testing | kubectl apply -f -

test-e2e: export KUBECONFIG = ${PWD}/kubeconfig
test-e2e: kind-create kustomize kind-deploy $(KUTTL) ## Run kuttl e2e tests in the k8s kind cluster
test-e2e: kind-create kustomize kind-deploy $(KUTTL) ## Run kuttl e2e tests in the k8s kind cluster.
$(KUTTL)
Loading
Loading