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

K8SPSMDB-1183 bundle generations for psmdb #1681

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ce0549c
K8SPSMDB-1183 bundle generations for psmdb
nmarukovich Oct 21, 2024
9f6df70
fix bundle generation
nmarukovich Dec 27, 2024
d3a4fa8
Merge branch 'main' into K8SPSMDB-1183_bundle_generation
nmarukovich Jan 3, 2025
6fda65b
Merge branch 'main' into K8SPSMDB-1183_bundle_generation
nmarukovich Jan 6, 2025
c381cfe
delete unused
nmarukovich Jan 10, 2025
fd623d4
Merge branch 'K8SPSMDB-1183_bundle_generation' of github.com:percona/…
nmarukovich Jan 10, 2025
d68eb54
update readme and makefile
nmarukovich Jan 20, 2025
e454177
add automatic operator copy
nmarukovich Jan 20, 2025
58fc067
fix kustomization for namespace
nmarukovich Jan 20, 2025
b9c35f9
add rbac copy to config
nmarukovich Jan 20, 2025
ffbb6af
update readme
nmarukovich Jan 20, 2025
a7c5d1b
add instructions to readme
nmarukovich Jan 21, 2025
1efff38
fix labels
nmarukovich Jan 21, 2025
46535d6
update mode usage
nmarukovich Jan 21, 2025
b624e8c
add --- to the crds
nmarukovich Feb 3, 2025
ad41057
Merge branch 'main' into K8SPSMDB-1183_bundle_generation
nmarukovich Feb 3, 2025
9e38418
fix secret indent
nmarukovich Feb 4, 2025
7092c53
Merge branch 'K8SPSMDB-1183_bundle_generation' of github.com:percona/…
nmarukovich Feb 4, 2025
58dfeba
Merge branch 'main' into K8SPSMDB-1183_bundle_generation
nmarukovich Feb 5, 2025
2092956
Apply suggestions from code review
nmarukovich Feb 10, 2025
eef7751
Update installers/olm/generate.sh
nmarukovich Feb 11, 2025
e20263a
Apply suggestions from code review
nmarukovich Feb 11, 2025
c88d5e3
Merge branch 'main' into K8SPSMDB-1183_bundle_generation
nmarukovich Feb 11, 2025
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* @hors @egegunes @pooknull @nmarukovich @gkech
/e2e-tests/ @ptankov @jvpasinatto @eleo007
Jenkinsfile @ptankov @jvpasinatto @eleo007

2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ updates:
time: "01:00"
reviewers:
- hors
- tplavcic
- nmarukovich
ignore:
# ignore patch updates for all dependencies
- dependency-name: "*"
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,7 @@ bin/
### VisualStudioCode ###
.vscode/*
.history

projects/
installers/olm/operator_*.yaml
installers/olm/bundles
10 changes: 10 additions & 0 deletions config/bundle/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../crd
- ../rbac/namespace
- ../manager/namespace
images:
- name: percona-server-mongodb-operator
newName: perconalab/percona-server-mongodb-operator
newTag: main
5 changes: 5 additions & 0 deletions config/community/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../operator
2 changes: 1 addition & 1 deletion config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ resources:
- bases/psmdb.percona.com_perconaservermongodbs.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patchesJson6902:
patches:
- path: patches/deprecated-1.2.json
target:
name: perconaservermongodbs.psmdb.percona.com
Expand Down
8 changes: 8 additions & 0 deletions config/manager/cluster/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- cw-operator.yaml
images:
- name: psmdb-operator
newName: perconalab/percona-server-mongodb-operator
newTag: main
8 changes: 8 additions & 0 deletions config/manager/namespace/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- operator.yaml
images:
- name: psmdb-operator
newName: perconalab/percona-server-mongodb-operator
newTag: main
6 changes: 6 additions & 0 deletions config/marketplace/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../operator

6 changes: 6 additions & 0 deletions config/operator/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../bundle

7 changes: 7 additions & 0 deletions config/rbac/cluster/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- service_account.yaml
- role.yaml
- role_binding.yaml
7 changes: 7 additions & 0 deletions config/rbac/namespace/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- service_account.yaml
- role.yaml
- role_binding.yaml
6 changes: 6 additions & 0 deletions config/redhat/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../operator

139 changes: 139 additions & 0 deletions installers/olm/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
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:

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

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

REPO_ROOT = $(shell git rev-parse --show-toplevel)

distros = community redhat marketplace

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

KUSTOMIZE = $(REPO_ROOT)/bin/kustomize
kustomize: ## Download kustomize locally if necessary.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not work for me, when I execute make bundles I get an error in this line:
/bin/bash: ..repos/percona-server-mongodb-operator/bin/kustomize: No such file or directory

Yes, I don't have kustomize in bin/ folder, but this go-get-tool should be able to download it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I will check it too. And I agree that go-get-tool should download it.

$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v4@v4.5.3)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we update this? I see in github there is v5.5.0 version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use this version for all our operators in all our makefile. I can check can we update it or not)


.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)"

# 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: 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)

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

.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.21.txt)/bin/$(OS_KERNEL)/$(OS_MACHINE)/kubectl'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we update this? stable-1.21

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which one do you want to use?

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.19.1/operator-sdk_$(OS_KERNEL)_$(OS_MACHINE)'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we update this?

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.33.0/$(OS_KERNEL)-$(OS_MACHINE)-opm'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we update this? Also, shoud this be aligned with the version from operator-sdk?

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

23 changes: 23 additions & 0 deletions installers/olm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
1. To generate bundle correctly please set env variables (default values for these variables you can check in makefile):
```bash
# operator version
export VERSION=1.18.0
# By default we use perconalab for tag owner. Please update this variable to use another repo
export IMAGE_TAG_OWNER=percona
# Min k8s version
export MIN_KUBE_VERSION=1.27.0
# Openshift versions:
export OPENSHIFT_VERSIONS="v4.13-v4.16"
# Set namespace or cluster (to generate bundles for cluster-wide)
export MODE=namespace
```
2. Also it could be useful to check variable in makefile and update if you need something extra. For the most cases to update these variables is enough
3. Update spec.description in bundle.csv.yaml with features added in this release.
4. Run bundle generation:
```bash
# Generate all bundles community redhat and marketplace:
make bundles
# Generate only specific bundle:
make bundles/community
```

15 changes: 15 additions & 0 deletions installers/olm/bundle.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Used to build the bundle image. This file is ignored by the community operator
# registries which work with bundle directories instead.
# https://operator-framework.github.io/community-operators/packaging-operator/

FROM scratch AS builder

COPY manifests/ /build/manifests/
COPY metadata/ /build/metadata/

FROM scratch

# LABELS is replaced with bundle.annotations.yaml
${LABELS}

COPY --from=builder /build/ /
12 changes: 12 additions & 0 deletions installers/olm/bundle.annotations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
annotations:
operators.operatorframework.io.bundle.mediatype.v1: registry+v1
operators.operatorframework.io.bundle.manifests.v1: manifests/
operators.operatorframework.io.bundle.metadata.v1: metadata/
operators.operatorframework.io.bundle.package.v1: percona-server-mongodb-operator
operators.operatorframework.io.bundle.channels.v1: stable
operators.operatorframework.io.bundle.channel.default.v1: stable
com.redhat.openshift.versions: 'v4.13'
org.opencontainers.image.authors: info@percona.com
org.opencontainers.image.url: https://percona.com
org.opencontainers.image.vendor: Percona
Loading
Loading