-
Notifications
You must be signed in to change notification settings - Fork 150
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
base: main
Are you sure you want to change the base?
Changes from 11 commits
ce0549c
9f6df70
d3a4fa8
6fda65b
c381cfe
fd623d4
d68eb54
e454177
58fc067
b9c35f9
ffbb6af
a7c5d1b
1efff38
46535d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
* @hors @egegunes @inelpandzic @pooknull | ||
* @hors @egegunes @inelpandzic @pooknull @nmarukovich | ||
/e2e-tests/ @nmarukovich @ptankov @jvpasinatto @eleo007 | ||
Jenkinsfile @nmarukovich @ptankov @jvpasinatto @eleo007 |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
resources: | ||
- ../operator |
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 |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
resources: | ||
- ../operator | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
resources: | ||
- ../bundle | ||
|
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 |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
resources: | ||
- ../operator | ||
|
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. | ||
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we update this? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
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) | ||
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. Choose the mode (cluster (for cluster-wide) or namespace) and update config/bundle/kustomization.yaml. | ||
```yaml | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- ../crd | ||
- ../rbac/namespace # replace namespace to cluster for cluster-wide | ||
- ../manager/namespace # replace namespace to cluster for cluster-wide | ||
images: | ||
- name: percona-server-mongodb-operator | ||
newName: perconalab/percona-server-mongodb-operator | ||
newTag: main | ||
``` | ||
4. Update spec.description in bundle.csv.yaml with features added in this release. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. give full path |
||
5. Run bundle generation: | ||
```make bundles``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# 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 | ||
|
||
# ANNOTATIONS is replaced with bundle.annotations.yaml | ||
LABEL \ | ||
${ANNOTATIONS} | ||
|
||
COPY --from=builder /build/ / |
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: [email protected] | ||
org.opencontainers.image.url: https://percona.com | ||
org.opencontainers.image.vendor: Percona |
There was a problem hiding this comment.
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 itThere was a problem hiding this comment.
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.