Skip to content
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
261 changes: 153 additions & 108 deletions installers/olm/Makefile
Original file line number Diff line number Diff line change
@@ -1,139 +1,184 @@
# ==============================================================================
# Percona Server MongoDB Operator - OLM Bundle Generation
# ==============================================================================

# Default target
.DEFAULT_GOAL := help
.SUFFIXES:
SHELL := /bin/bash

# ==============================================================================
# Configuration Variables
# ==============================================================================

# Project configuration
NAME ?= percona-server-mongodb-operator
IMAGE_TAG_OWNER ?= perconalab
IMAGE_TAG_BASE ?= $(IMAGE_TAG_OWNER)/$(NAME)
SED := $(shell which gsed || which sed)
VERSION ?= $(shell git rev-parse --abbrev-ref HEAD | $(SED) -e 's^/^-^g; s^[.]^-^g;' | tr '[:upper:]' '[:lower:]')
IMAGE ?= $(IMAGE_TAG_BASE):$(VERSION)
MODE ?= namespace
DEPLOYDIR = ./deploy

BUNDLEDIR = $(DEPLOYDIR)/csv/redhat
BUNDLE_CHANNELS := --channels=stable
BUNDLE_DEFAULT_CHANNEL := --default-channel=stable
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)

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

CONTAINER ?= docker
OPENSHIFT_VERSIONS ?= v4.13-v4.16
# Bundle configuration
OPENSHIFT_VERSIONS ?= v4.16-v4.19
PACKAGE_CHANNEL ?= stable
MIN_KUBE_VERSION ?= 1.24.0
MIN_KUBE_VERSION ?= ""
DOCKER_DEFAULT_PLATFORM ?= linux/amd64
SHELL := /bin/bash
REPO_ROOT = $(shell git rev-parse --show-toplevel)

# Paths
REPO_ROOT := $(shell git rev-parse --show-toplevel)
KUSTOMIZE := $(REPO_ROOT)/bin/kustomize

# Tool versions
OPERATOR_SDK_VERSION := v1.41.1

# Bundle image configuration
BUNDLE_IMG ?= $(IMAGE_TAG_BASE):community-bundle-$(VERSION)

# System detection for tool downloads
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
OS_KERNEL := $(shell echo "$(UNAME_S)" | tr '[:upper:]' '[:lower:]')
OS_MACHINE := $(UNAME_M)

# Display colors
GREEN := $(shell tput setaf 2)
RESET := $(shell tput sgr0)

export VERSION
export BUNDLE_REPO
export OPENSHIFT_VERSIONS
export PACKAGE_CHANNEL
export MIN_KUBE_VERSION
export DOCKER_DEFAULT_PLATFORM
export MODE
# Export variables for generate.sh
export VERSION OPENSHIFT_VERSIONS PACKAGE_CHANNEL MIN_KUBE_VERSION DOCKER_DEFAULT_PLATFORM MODE

# ==============================================================================
# Bundle Targets
# ==============================================================================

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

distros = community redhat marketplace
.PHONY: bundles
bundles: ## Build all OLM bundles (community, redhat, marketplace)
bundles: check-prereqs $(DISTROS:%=bundles/%)

.PHONY: $(DISTROS:%=bundles/%)
$(DISTROS:%=bundles/%): bundles/%: tools/operator-sdk
@echo "$(GREEN)Building $* bundle...$(RESET)"
cd ../../config/manager/$(MODE)/ && $(KUSTOMIZE) edit set image psmdb-operator=$(IMAGE)
./generate.sh $*
./tools/operator-sdk bundle validate $@ --select-optional='suite=operatorframework'
$(if $(filter community,$*),./tools/operator-sdk bundle validate $@ --select-optional='name=community' --optional-values='index-path=$@/Dockerfile')
@echo "$(GREEN)✓ Bundle stored in installers/olm/bundles/$*$(RESET)"

# ==============================================================================
# Docker Build & Push Targets
# ==============================================================================

.PHONY: build
build: ## Build community bundle Docker image
build:
@echo "$(GREEN)Building bundle Docker image...$(RESET)"
docker build -f bundles/community/Dockerfile -t $(BUNDLE_IMG) --platform=linux/amd64 bundles/community
@echo "$(GREEN)✓ Bundle image built: $(BUNDLE_IMG)$(RESET)"

.PHONY: push
push: ## Push bundle Docker image to registry
@echo "$(GREEN)Pushing bundle image to registry...$(RESET)"
docker push $(BUNDLE_IMG)
@echo "$(GREEN)✓ Bundle image pushed: $(BUNDLE_IMG)$(RESET)"

# ==============================================================================
# Utility Targets
# ==============================================================================

.PHONY: check-prereqs
check-prereqs: check-version check-git check-tools

.PHONY: check-version
check-version:
ifndef VERSION
$(error VERSION is not set)
endif

KUSTOMIZE = $(REPO_ROOT)/bin/kustomize
kustomize: ## Download kustomize locally if necessary.
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected])

.PHONY: bundles
bundles: ## Build OLM bundles
bundles: check-version $(distros:%=bundles/%)

# https://olm.operatorframework.io/docs/tasks/creating-operator-bundle/#validating-your-bundle
# https://github.com/operator-framework/community-operators/blob/8a36a33/docs/packaging-required-criteria-ocp.md
.PHONY: bundles/community
bundles/community:
cd ../../config/manager/$(MODE)/ && $(KUSTOMIZE) edit set image psmdb-operator=$(IMAGE)
./generate.sh community

env operator-sdk bundle validate $@ --select-optional='suite=operatorframework'
env operator-sdk bundle validate $@ --select-optional='name=community' --optional-values='index-path=$@/Dockerfile'
@echo "$(GREEN)!!!!!!!!!!! Build stored in installers/olm/bundles/community !!!!!!!!!!!!!!!$(RESET)"

.PHONY: bundles/redhat
bundles/redhat:
cd ../../config/manager/$(MODE)/ && $(KUSTOMIZE) edit set image psmdb-operator=$(IMAGE)
./generate.sh redhat
env operator-sdk bundle validate $@ --select-optional='suite=operatorframework'
@echo "$(GREEN)!!!!!!!!!!! Build stored in installers/olm/bundles/redhat !!!!!!!!!!!!!!!$(RESET)"
.PHONY: check-git
check-git:
@if ! git rev-parse --git-dir > /dev/null 2>&1; then \
echo "Error: Not in a git repository"; \
exit 1; \
fi

.PHONY: check-tools
check-tools:
@for cmd in gawk gcsplit yq; do \
if ! command -v $$cmd >/dev/null 2>&1; then \
echo "Error: $$cmd is required but not installed"; \
exit 1; \
fi; \
done

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

.PHONY: clean
clean: clean-deprecated
clean: ## Remove generated files and downloaded tools
rm -rf ./bundles ./projects ./tools

.PHONY: clean-deprecated
clean-deprecated:
rm -rf ./package

.PHONY: help
help: ALIGN=18
help: ## Print this message
@awk -F ': ## ' -- "/^[^':]+: ## /"' { printf "'$$(tput bold)'%-$(ALIGN)s'$$(tput sgr0)' %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
help: ## Show this help message
@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)

.PHONY: install-olm
install-olm: ## Install OLM in Kubernetes
env operator-sdk olm install
# ==============================================================================
# Tool Management
# ==============================================================================

.PHONY: tools
tools: ## Download tools needed to build bundles

tools: tools/$(SYSTEM)/jq
tools/$(SYSTEM)/jq:
install -d '$(dir $@)'
curl -fSL -o '$@' "https://github.com/stedolan/jq/releases/download/jq-1.7.1/jq-$$(SYSTEM='$(SYSTEM)'; \
case "$$SYSTEM" in \
(linux-*) echo "$${SYSTEM/-amd/}";; (darwin-*) echo "$${SYSTEM/darwin-*/osx-amd64}";; (*) echo '$(SYSTEM)';; \
esac)"
chmod u+x '$@'

tools: tools/$(SYSTEM)/kubectl
tools/$(SYSTEM)/kubectl:
install -d '$(dir $@)'
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'
chmod u+x '$@'

# quay.io/operator-framework/operator-sdk
tools: tools/$(SYSTEM)/operator-sdk
tools/$(SYSTEM)/operator-sdk:
install -d '$(dir $@)'
curl -fSL -o '$@' 'https://github.com/operator-framework/operator-sdk/releases/download/v1.39.1/operator-sdk_$(OS_KERNEL)_$(OS_MACHINE)'
chmod u+x '$@'

tools: tools/$(SYSTEM)/opm
tools/$(SYSTEM)/opm:
install -d '$(dir $@)'
curl -fSL -o '$@' 'https://github.com/operator-framework/operator-registry/releases/download/v1.50.0/$(OS_KERNEL)-$(OS_MACHINE)-opm'
chmod u+x '$@'

tools/$(SYSTEM)/venv:
install -d '$(dir $@)'
python3 -m venv '$@'

tools: tools/$(SYSTEM)/yq
tools/$(SYSTEM)/yq: | tools/$(SYSTEM)/venv
'tools/$(SYSTEM)/venv/bin/python' -m pip install yq
cd '$(dir $@)' && ln -s venv/bin/yq
tools: ## Download required tools
tools: tools/operator-sdk

# Download operator-sdk
tools/operator-sdk:
@echo "Downloading operator-sdk $(OPERATOR_SDK_VERSION)..."
@install -d tools
@curl -fSL --fail -o '$@' \
'https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$(OS_KERNEL)_$(OS_MACHINE)' \
|| { rm -f '$@'; echo "Failed to download operator-sdk"; exit 1; }
@chmod +x '$@'
@echo "✓ operator-sdk installed"

# ==============================================================================
# Development Targets
# ==============================================================================

.PHONY: validate
validate: ## Validate existing bundles without rebuilding
@for distro in $(DISTROS); do \
if [ -d "bundles/$$distro" ]; then \
echo "Validating $$distro bundle..."; \
./tools/operator-sdk bundle validate "bundles/$$distro" --select-optional='suite=operatorframework' || exit 1; \
fi; \
done
@echo "$(GREEN)✓ All bundles validated$(RESET)"

.PHONY: list-versions
list-versions: ## Show current version information
@echo "Current configuration:"
@echo " VERSION: $(VERSION)"
@echo " IMAGE: $(IMAGE)"
@echo " MODE: $(MODE)"
@echo " OPENSHIFT_VERSIONS: $(OPENSHIFT_VERSIONS)"
@echo " MIN_KUBE_VERSION: $(MIN_KUBE_VERSION)"

# ==============================================================================
# Kustomize Integration (from root Makefile)
# ==============================================================================

# Include go-get-tool function from root Makefile if kustomize target is needed
ifneq (,$(findstring kustomize,$(MAKECMDGOALS)))
include ../../Makefile
endif

.PHONY: kustomize
kustomize: ## Download kustomize locally if necessary
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v4@latest)
37 changes: 4 additions & 33 deletions installers/olm/bundle.csv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: operators.coreos.com/v1alpha1
kind: ClusterServiceVersion
metadata:
name:
namespace: default
annotations:
features.operators.openshift.io/disconnected: "false"
features.operators.openshift.io/fips-compliant: "false"
Expand Down Expand Up @@ -71,9 +72,9 @@ spec:
are performed using Percona Backup for MongoDB (PBM) and can be stored on
local PVs or in any S3-compatible cloud storage provider.

* **Physical Backups - [configure physical backups](https://docs.percona.com/percona-operator-for-mongodb/backups.html#physical)
* **Physical Backups** - [configure physical backups](https://docs.percona.com/percona-operator-for-mongodb/backups.html#physical)

* **Automated volume expansion
* **Automated volume expansion**
Kubernetes supports the Persistent Volume expansion as a stable feature since v1.24. Using it with the Operator
previously involved manual operations. Now this is automated, and users can resize their PVCs by just changing
the value of the resources.requests.storage option in the PerconaServerMongoDB custom resource.
Expand Down Expand Up @@ -115,15 +116,11 @@ spec:


```

apiVersion: v1

kind: Secret

metadata:
name: my-cluster-name-secrets
type: Opaque

data:
MONGODB_BACKUP_USER: YmFja3Vw
MONGODB_BACKUP_PASSWORD: YmFja3VwMTIzNDU2
Expand All @@ -137,32 +134,6 @@ spec:
MONGODB_USER_ADMIN_PASSWORD: dXNlckFkbWluMTIzNDU2
PMM_SERVER_API_KEY: dXNlckFkbWluMTIzNDU2
```

### Release Highlights
* General availability of Physical Backups
Two releases ago we added experimental support for Physical Backups and Restores to significantly reduce Recovery Time Objective (RTO ),
especially for big data sets. With this release Percona announces the general availability of physical backups and restores for
Percona Server for MongoDB with the Operator.

* Automated volume expansion
Kubernetes supports the Persistent Volume expansion as a stable feature since v1.24. Using it with the Operator previously involved
manual operations. Now this is automated, and users can resize their PVCs by just changing the value of the resources.requests.storage
option in the PerconaServerMongoDB custom resource. This feature is in a technical preview stage and is not recommended
for production environments.

* Support for MongoDB 7
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 .

* Support for ARM architecture (technical preview)
ARM architecture meets the intensive growth of its usage nowadays, both in a segment of highly efficient cloud computing based on systems
like AWS Graviton, and the Internet of Things or Edge. Officially certified images for ARM are now available for the Operator,
as well as Percona Server for MongoDB and Percona Backup for MongoDB, while database monitoring based on PMM Client is yet to follow.

* Fixing the overloaded allowUnsafeConfigurations flag
In the previous Operator versions allowUnsafeConfigurations Custom Resource option was used to allow configuring a cluster
with unsafe parameters, such as starting it with less than 3 replica set instances. In fact, setting this option to true
resulted in a wide range of reduced safety features without the user’s explicit intent: disabling TLS,
allowing backups in unhealthy clusters, etc.

version: ''
links:
Expand All @@ -171,7 +142,7 @@ spec:
- name: Percona Kubernetes Operators Landing Page
url: 'https://www.percona.com/software/percona-kubernetes-operators'
- name: Documentation
url: 'https://percona.github.io/percona-server-mongodb-operator/'
url: 'https://docs.percona.com/percona-operator-for-mongodb/'
- name: Github
url: 'https://github.com/percona/percona-server-mongodb-operator'
maintainers:
Expand Down
11 changes: 6 additions & 5 deletions installers/olm/bundle.relatedImages.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
- name: mongod8.0
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:<update_mongod8.0_SHA_value>
- name: mongod7.0
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:<update_mongod7.0_SHA_value>
- name: mongod6.0
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:<update_mongod6.0_SHA_value>
- name: mongod5.0
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:<update_mongod5.0_SHA_value>
- name: backup
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:<update_backup_SHA_value>
- name: pmm
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:<update_pmm_SHA_value>
- name: pmm3
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:<update_pmm3_SHA_value>
- name: logcollector
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:<update_logcollector_SHA_value>
- name: operator
image: registry.connect.redhat.com/percona/percona-server-mongodb-operator@sha256:<update_operator_SHA_value>



Loading