Skip to content

Commit 282b19b

Browse files
authored
Fix bundle generation Makefile (#2091)
1 parent eda57dc commit 282b19b

File tree

3 files changed

+163
-146
lines changed

3 files changed

+163
-146
lines changed

installers/olm/Makefile

Lines changed: 153 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,184 @@
1+
# ==============================================================================
2+
# Percona Server MongoDB Operator - OLM Bundle Generation
3+
# ==============================================================================
4+
5+
# Default target
6+
.DEFAULT_GOAL := help
7+
.SUFFIXES:
8+
SHELL := /bin/bash
9+
10+
# ==============================================================================
11+
# Configuration Variables
12+
# ==============================================================================
13+
14+
# Project configuration
115
NAME ?= percona-server-mongodb-operator
216
IMAGE_TAG_OWNER ?= perconalab
317
IMAGE_TAG_BASE ?= $(IMAGE_TAG_OWNER)/$(NAME)
4-
SED := $(shell which gsed || which sed)
5-
VERSION ?= $(shell git rev-parse --abbrev-ref HEAD | $(SED) -e 's^/^-^g; s^[.]^-^g;' | tr '[:upper:]' '[:lower:]')
6-
IMAGE ?= $(IMAGE_TAG_BASE):$(VERSION)
718
MODE ?= namespace
8-
DEPLOYDIR = ./deploy
9-
10-
BUNDLEDIR = $(DEPLOYDIR)/csv/redhat
11-
BUNDLE_CHANNELS := --channels=stable
12-
BUNDLE_DEFAULT_CHANNEL := --default-channel=stable
13-
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
1419

15-
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
16-
ENVTEST_K8S_VERSION = 1.23
17-
.DEFAULT_GOAL := help
18-
.SUFFIXES:
20+
# Version detection
21+
SED := $(shell which gsed || which sed)
22+
VERSION ?= $(shell git rev-parse --abbrev-ref HEAD | $(SED) -e 's^/^-^g; s^[.]^-^g;' | tr '[:upper:]' '[:lower:]')
23+
IMAGE := $(IMAGE_TAG_BASE):$(VERSION)
1924

20-
CONTAINER ?= docker
21-
OPENSHIFT_VERSIONS ?= v4.13-v4.16
25+
# Bundle configuration
26+
OPENSHIFT_VERSIONS ?= v4.16-v4.19
2227
PACKAGE_CHANNEL ?= stable
23-
MIN_KUBE_VERSION ?= 1.24.0
28+
MIN_KUBE_VERSION ?= ""
2429
DOCKER_DEFAULT_PLATFORM ?= linux/amd64
25-
SHELL := /bin/bash
26-
REPO_ROOT = $(shell git rev-parse --show-toplevel)
2730

31+
# Paths
32+
REPO_ROOT := $(shell git rev-parse --show-toplevel)
33+
KUSTOMIZE := $(REPO_ROOT)/bin/kustomize
34+
35+
# Tool versions
36+
OPERATOR_SDK_VERSION := v1.41.1
37+
38+
# Bundle image configuration
39+
BUNDLE_IMG ?= $(IMAGE_TAG_BASE):community-bundle-$(VERSION)
40+
41+
# System detection for tool downloads
42+
UNAME_S := $(shell uname -s)
43+
UNAME_M := $(shell uname -m)
44+
OS_KERNEL := $(shell echo "$(UNAME_S)" | tr '[:upper:]' '[:lower:]')
45+
OS_MACHINE := $(UNAME_M)
46+
47+
# Display colors
2848
GREEN := $(shell tput setaf 2)
2949
RESET := $(shell tput sgr0)
3050

31-
export VERSION
32-
export BUNDLE_REPO
33-
export OPENSHIFT_VERSIONS
34-
export PACKAGE_CHANNEL
35-
export MIN_KUBE_VERSION
36-
export DOCKER_DEFAULT_PLATFORM
37-
export MODE
51+
# Export variables for generate.sh
52+
export VERSION OPENSHIFT_VERSIONS PACKAGE_CHANNEL MIN_KUBE_VERSION DOCKER_DEFAULT_PLATFORM MODE
53+
54+
# ==============================================================================
55+
# Bundle Targets
56+
# ==============================================================================
3857

39-
REPO_ROOT = $(shell git rev-parse --show-toplevel)
58+
DISTROS := community redhat marketplace
4059

41-
distros = community redhat marketplace
60+
.PHONY: bundles
61+
bundles: ## Build all OLM bundles (community, redhat, marketplace)
62+
bundles: check-prereqs $(DISTROS:%=bundles/%)
4263

64+
.PHONY: $(DISTROS:%=bundles/%)
65+
$(DISTROS:%=bundles/%): bundles/%: tools/operator-sdk
66+
@echo "$(GREEN)Building $* bundle...$(RESET)"
67+
cd ../../config/manager/$(MODE)/ && $(KUSTOMIZE) edit set image psmdb-operator=$(IMAGE)
68+
./generate.sh $*
69+
./tools/operator-sdk bundle validate $@ --select-optional='suite=operatorframework'
70+
$(if $(filter community,$*),./tools/operator-sdk bundle validate $@ --select-optional='name=community' --optional-values='index-path=$@/Dockerfile')
71+
@echo "$(GREEN)✓ Bundle stored in installers/olm/bundles/$*$(RESET)"
72+
73+
# ==============================================================================
74+
# Docker Build & Push Targets
75+
# ==============================================================================
76+
77+
.PHONY: build
78+
build: ## Build community bundle Docker image
79+
build:
80+
@echo "$(GREEN)Building bundle Docker image...$(RESET)"
81+
docker build -f bundles/community/Dockerfile -t $(BUNDLE_IMG) --platform=linux/amd64 bundles/community
82+
@echo "$(GREEN)✓ Bundle image built: $(BUNDLE_IMG)$(RESET)"
83+
84+
.PHONY: push
85+
push: ## Push bundle Docker image to registry
86+
@echo "$(GREEN)Pushing bundle image to registry...$(RESET)"
87+
docker push $(BUNDLE_IMG)
88+
@echo "$(GREEN)✓ Bundle image pushed: $(BUNDLE_IMG)$(RESET)"
89+
90+
# ==============================================================================
91+
# Utility Targets
92+
# ==============================================================================
93+
94+
.PHONY: check-prereqs
95+
check-prereqs: check-version check-git check-tools
96+
97+
.PHONY: check-version
4398
check-version:
4499
ifndef VERSION
45100
$(error VERSION is not set)
46101
endif
47102

48-
KUSTOMIZE = $(REPO_ROOT)/bin/kustomize
49-
kustomize: ## Download kustomize locally if necessary.
50-
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected])
51-
52-
.PHONY: bundles
53-
bundles: ## Build OLM bundles
54-
bundles: check-version $(distros:%=bundles/%)
55-
56-
# https://olm.operatorframework.io/docs/tasks/creating-operator-bundle/#validating-your-bundle
57-
# https://github.com/operator-framework/community-operators/blob/8a36a33/docs/packaging-required-criteria-ocp.md
58-
.PHONY: bundles/community
59-
bundles/community:
60-
cd ../../config/manager/$(MODE)/ && $(KUSTOMIZE) edit set image psmdb-operator=$(IMAGE)
61-
./generate.sh community
62-
63-
env operator-sdk bundle validate $@ --select-optional='suite=operatorframework'
64-
env operator-sdk bundle validate $@ --select-optional='name=community' --optional-values='index-path=$@/Dockerfile'
65-
@echo "$(GREEN)!!!!!!!!!!! Build stored in installers/olm/bundles/community !!!!!!!!!!!!!!!$(RESET)"
66-
67-
.PHONY: bundles/redhat
68-
bundles/redhat:
69-
cd ../../config/manager/$(MODE)/ && $(KUSTOMIZE) edit set image psmdb-operator=$(IMAGE)
70-
./generate.sh redhat
71-
env operator-sdk bundle validate $@ --select-optional='suite=operatorframework'
72-
@echo "$(GREEN)!!!!!!!!!!! Build stored in installers/olm/bundles/redhat !!!!!!!!!!!!!!!$(RESET)"
103+
.PHONY: check-git
104+
check-git:
105+
@if ! git rev-parse --git-dir > /dev/null 2>&1; then \
106+
echo "Error: Not in a git repository"; \
107+
exit 1; \
108+
fi
109+
110+
.PHONY: check-tools
111+
check-tools:
112+
@for cmd in gawk gcsplit yq; do \
113+
if ! command -v $$cmd >/dev/null 2>&1; then \
114+
echo "Error: $$cmd is required but not installed"; \
115+
exit 1; \
116+
fi; \
117+
done
73118

74-
# The 'marketplace' configuration is currently identical to the 'redhat', so we just copy it here.
75-
.PHONY: bundles/marketplace
76-
bundles/marketplace:
77-
cd ../../config/manager/$(MODE)/ && $(KUSTOMIZE) edit set image psmdb-operator=$(IMAGE)
78-
./generate.sh marketplace
79-
env operator-sdk bundle validate $@ --select-optional='suite=operatorframework'
80-
@echo "$(GREEN)!!!!!!!!!!! Build stored in installers/olm/bundles/marketplace !!!!!!!!!!!!!!!$(RESET)"
119+
.PHONY: install-olm
120+
install-olm: ## Install OLM in Kubernetes cluster
121+
install-olm: tools/operator-sdk
122+
./tools/operator-sdk olm install
81123

82124
.PHONY: clean
83-
clean: clean-deprecated
84125
clean: ## Remove generated files and downloaded tools
85126
rm -rf ./bundles ./projects ./tools
86127

87-
.PHONY: clean-deprecated
88-
clean-deprecated:
89-
rm -rf ./package
90-
91128
.PHONY: help
92-
help: ALIGN=18
93-
help: ## Print this message
94-
@awk -F ': ## ' -- "/^[^':]+: ## /"' { printf "'$$(tput bold)'%-$(ALIGN)s'$$(tput sgr0)' %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
129+
help: ## Show this help message
130+
@awk 'BEGIN {FS = ": ## "; printf "\n$(GREEN)Usage:$(RESET)\n make [target]\n\n$(GREEN)Targets:$(RESET)\n"} /^[a-zA-Z_-]+: ## / {printf " %-20s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
95131

96-
.PHONY: install-olm
97-
install-olm: ## Install OLM in Kubernetes
98-
env operator-sdk olm install
132+
# ==============================================================================
133+
# Tool Management
134+
# ==============================================================================
99135

100136
.PHONY: tools
101-
tools: ## Download tools needed to build bundles
102-
103-
tools: tools/$(SYSTEM)/jq
104-
tools/$(SYSTEM)/jq:
105-
install -d '$(dir $@)'
106-
curl -fSL -o '$@' "https://github.com/stedolan/jq/releases/download/jq-1.7.1/jq-$$(SYSTEM='$(SYSTEM)'; \
107-
case "$$SYSTEM" in \
108-
(linux-*) echo "$${SYSTEM/-amd/}";; (darwin-*) echo "$${SYSTEM/darwin-*/osx-amd64}";; (*) echo '$(SYSTEM)';; \
109-
esac)"
110-
chmod u+x '$@'
111-
112-
tools: tools/$(SYSTEM)/kubectl
113-
tools/$(SYSTEM)/kubectl:
114-
install -d '$(dir $@)'
115-
curl -fSL -o '$@' 'https://dl.k8s.io/release/$(shell curl -Ls https://dl.k8s.io/release/stable-1.31.txt)/bin/$(OS_KERNEL)/$(OS_MACHINE)/kubectl'
116-
chmod u+x '$@'
117-
118-
# quay.io/operator-framework/operator-sdk
119-
tools: tools/$(SYSTEM)/operator-sdk
120-
tools/$(SYSTEM)/operator-sdk:
121-
install -d '$(dir $@)'
122-
curl -fSL -o '$@' 'https://github.com/operator-framework/operator-sdk/releases/download/v1.39.1/operator-sdk_$(OS_KERNEL)_$(OS_MACHINE)'
123-
chmod u+x '$@'
124-
125-
tools: tools/$(SYSTEM)/opm
126-
tools/$(SYSTEM)/opm:
127-
install -d '$(dir $@)'
128-
curl -fSL -o '$@' 'https://github.com/operator-framework/operator-registry/releases/download/v1.50.0/$(OS_KERNEL)-$(OS_MACHINE)-opm'
129-
chmod u+x '$@'
130-
131-
tools/$(SYSTEM)/venv:
132-
install -d '$(dir $@)'
133-
python3 -m venv '$@'
134-
135-
tools: tools/$(SYSTEM)/yq
136-
tools/$(SYSTEM)/yq: | tools/$(SYSTEM)/venv
137-
'tools/$(SYSTEM)/venv/bin/python' -m pip install yq
138-
cd '$(dir $@)' && ln -s venv/bin/yq
137+
tools: ## Download required tools
138+
tools: tools/operator-sdk
139+
140+
# Download operator-sdk
141+
tools/operator-sdk:
142+
@echo "Downloading operator-sdk $(OPERATOR_SDK_VERSION)..."
143+
@install -d tools
144+
@curl -fSL --fail -o '$@' \
145+
'https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$(OS_KERNEL)_$(OS_MACHINE)' \
146+
|| { rm -f '$@'; echo "Failed to download operator-sdk"; exit 1; }
147+
@chmod +x '$@'
148+
@echo "✓ operator-sdk installed"
149+
150+
# ==============================================================================
151+
# Development Targets
152+
# ==============================================================================
153+
154+
.PHONY: validate
155+
validate: ## Validate existing bundles without rebuilding
156+
@for distro in $(DISTROS); do \
157+
if [ -d "bundles/$$distro" ]; then \
158+
echo "Validating $$distro bundle..."; \
159+
./tools/operator-sdk bundle validate "bundles/$$distro" --select-optional='suite=operatorframework' || exit 1; \
160+
fi; \
161+
done
162+
@echo "$(GREEN)✓ All bundles validated$(RESET)"
163+
164+
.PHONY: list-versions
165+
list-versions: ## Show current version information
166+
@echo "Current configuration:"
167+
@echo " VERSION: $(VERSION)"
168+
@echo " IMAGE: $(IMAGE)"
169+
@echo " MODE: $(MODE)"
170+
@echo " OPENSHIFT_VERSIONS: $(OPENSHIFT_VERSIONS)"
171+
@echo " MIN_KUBE_VERSION: $(MIN_KUBE_VERSION)"
172+
173+
# ==============================================================================
174+
# Kustomize Integration (from root Makefile)
175+
# ==============================================================================
176+
177+
# Include go-get-tool function from root Makefile if kustomize target is needed
178+
ifneq (,$(findstring kustomize,$(MAKECMDGOALS)))
179+
include ../../Makefile
180+
endif
139181

182+
.PHONY: kustomize
183+
kustomize: ## Download kustomize locally if necessary
184+
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v4@latest)

installers/olm/bundle.csv.yaml

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ apiVersion: operators.coreos.com/v1alpha1
33
kind: ClusterServiceVersion
44
metadata:
55
name:
6+
namespace: default
67
annotations:
78
features.operators.openshift.io/disconnected: "false"
89
features.operators.openshift.io/fips-compliant: "false"
@@ -71,9 +72,9 @@ spec:
7172
are performed using Percona Backup for MongoDB (PBM) and can be stored on
7273
local PVs or in any S3-compatible cloud storage provider.
7374
74-
* **Physical Backups - [configure physical backups](https://docs.percona.com/percona-operator-for-mongodb/backups.html#physical)
75+
* **Physical Backups** - [configure physical backups](https://docs.percona.com/percona-operator-for-mongodb/backups.html#physical)
7576
76-
* **Automated volume expansion
77+
* **Automated volume expansion**
7778
Kubernetes supports the Persistent Volume expansion as a stable feature since v1.24. Using it with the Operator
7879
previously involved manual operations. Now this is automated, and users can resize their PVCs by just changing
7980
the value of the resources.requests.storage option in the PerconaServerMongoDB custom resource.
@@ -115,15 +116,11 @@ spec:
115116
116117
117118
```
118-
119119
apiVersion: v1
120-
121120
kind: Secret
122-
123121
metadata:
124122
name: my-cluster-name-secrets
125123
type: Opaque
126-
127124
data:
128125
MONGODB_BACKUP_USER: YmFja3Vw
129126
MONGODB_BACKUP_PASSWORD: YmFja3VwMTIzNDU2
@@ -137,32 +134,6 @@ spec:
137134
MONGODB_USER_ADMIN_PASSWORD: dXNlckFkbWluMTIzNDU2
138135
PMM_SERVER_API_KEY: dXNlckFkbWluMTIzNDU2
139136
```
140-
141-
### Release Highlights
142-
* General availability of Physical Backups
143-
Two releases ago we added experimental support for Physical Backups and Restores to significantly reduce Recovery Time Objective (RTO ),
144-
especially for big data sets. With this release Percona announces the general availability of physical backups and restores for
145-
Percona Server for MongoDB with the Operator.
146-
147-
* Automated volume expansion
148-
Kubernetes supports the Persistent Volume expansion as a stable feature since v1.24. Using it with the Operator previously involved
149-
manual operations. Now this is automated, and users can resize their PVCs by just changing the value of the resources.requests.storage
150-
option in the PerconaServerMongoDB custom resource. This feature is in a technical preview stage and is not recommended
151-
for production environments.
152-
153-
* Support for MongoDB 7
154-
Starting from this release, MongoDB 7.0 is now supported. Read our take on top-5 changes in MongoDB version 7 in this blog post .
155-
156-
* Support for ARM architecture (technical preview)
157-
ARM architecture meets the intensive growth of its usage nowadays, both in a segment of highly efficient cloud computing based on systems
158-
like AWS Graviton, and the Internet of Things or Edge. Officially certified images for ARM are now available for the Operator,
159-
as well as Percona Server for MongoDB and Percona Backup for MongoDB, while database monitoring based on PMM Client is yet to follow.
160-
161-
* Fixing the overloaded allowUnsafeConfigurations flag
162-
In the previous Operator versions allowUnsafeConfigurations Custom Resource option was used to allow configuring a cluster
163-
with unsafe parameters, such as starting it with less than 3 replica set instances. In fact, setting this option to true
164-
resulted in a wide range of reduced safety features without the user’s explicit intent: disabling TLS,
165-
allowing backups in unhealthy clusters, etc.
166137
167138
version: ''
168139
links:
@@ -171,7 +142,7 @@ spec:
171142
- name: Percona Kubernetes Operators Landing Page
172143
url: 'https://www.percona.com/software/percona-kubernetes-operators'
173144
- name: Documentation
174-
url: 'https://percona.github.io/percona-server-mongodb-operator/'
145+
url: 'https://docs.percona.com/percona-operator-for-mongodb/'
175146
- name: Github
176147
url: 'https://github.com/percona/percona-server-mongodb-operator'
177148
maintainers:

installers/olm/bundle.relatedImages.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
- name: mongod8.0
2+
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:<update_mongod8.0_SHA_value>
13
- name: mongod7.0
24
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:<update_mongod7.0_SHA_value>
35
- name: mongod6.0
46
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:<update_mongod6.0_SHA_value>
5-
- name: mongod5.0
6-
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:<update_mongod5.0_SHA_value>
77
- name: backup
88
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:<update_backup_SHA_value>
99
- name: pmm
1010
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:<update_pmm_SHA_value>
11+
- name: pmm3
12+
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:<update_pmm3_SHA_value>
13+
- name: logcollector
14+
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:<update_logcollector_SHA_value>
1115
- name: operator
1216
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator@sha256:<update_operator_SHA_value>
13-
14-
15-

0 commit comments

Comments
 (0)