Skip to content

Commit

Permalink
Pelorus Operator v0.0.1 - Community Operator candidate
Browse files Browse the repository at this point in the history
Pelorus Operator which is the candidate for the Community Operator

To install:

operator-sdk run bundle quay.io/pelorus/pelorus-operator-bundle:v0.0.1 --namespace pelorus

Signed-off-by: Michal Pryc <mpryc@redhat.com>
  • Loading branch information
mpryc committed Dec 19, 2022
1 parent b3372dd commit 632446a
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 68 deletions.
4 changes: 2 additions & 2 deletions pelorus-operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,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.0.38
VERSION ?= 0.0.1

# 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 All @@ -29,7 +29,7 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
#
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
# pelorus.konveyor.io/pelorus-operator-bundle:$VERSION and pelorus.konveyor.io/pelorus-operator-catalog:$VERSION.
IMAGE_TAG_BASE ?= quay.io/migtools/pelorus-operator
IMAGE_TAG_BASE ?= quay.io/pelorus/pelorus-operator

# BUNDLE_IMG defines the image:tag used for the bundle.
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ metadata:
capabilities: Basic Install
categories: |
Modernization & Migration,Developer Tools,Monitoring,Integration & Delivery
createdAt: "2022-12-16T15:10:12Z"
containerImage: quay.io/pelorus/pelorus-operator:0.0.1
createdAt: "2022-12-19T11:26:21Z"
description: |
Tool that helps IT organizations measure their impact on the overall performance of their organization
operatorframework.io/suggested-namespace: pelorus
operators.operatorframework.io/builder: operator-sdk-v1.26.0
operators.operatorframework.io/project_layout: helm.sdk.operatorframework.io/v1
repository: https://github.com/konveyor/pelorus/
support: Pelorus Community
name: pelorus-operator.v0.0.38
name: pelorus-operator.v0.0.1
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -158,22 +159,6 @@ spec:
- clusterroles
verbs:
- '*'
- apiGroups:
- ""
resources:
- configmaps
- secrets
- serviceaccounts
- services
verbs:
- '*'
- apiGroups:
- rbac.authorization.k8s.io
resources:
- rolebindings
- roles
verbs:
- '*'
- apiGroups:
- apps.openshift.io
resources:
Expand Down Expand Up @@ -208,6 +193,22 @@ spec:
- routes
verbs:
- '*'
- apiGroups:
- ""
resources:
- configmaps
- secrets
- serviceaccounts
- services
verbs:
- '*'
- apiGroups:
- rbac.authorization.k8s.io
resources:
- rolebindings
- roles
verbs:
- '*'
- apiGroups:
- operators.coreos.com
resources:
Expand Down Expand Up @@ -357,7 +358,7 @@ spec:
- --metrics-bind-address=127.0.0.1:8080
- --leader-elect
- --leader-election-id=pelorus-operator
image: quay.io/migtools/pelorus-operator:0.0.38
image: quay.io/pelorus/pelorus-operator:0.0.1
livenessProbe:
httpGet:
path: /healthz
Expand Down Expand Up @@ -459,4 +460,4 @@ spec:
provider:
name: Red Hat
url: https://redhat.com
version: 0.0.38
version: 0.0.1
4 changes: 2 additions & 2 deletions pelorus-operator/config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: quay.io/migtools/pelorus-operator
newTag: 0.0.38
newName: quay.io/pelorus/pelorus-operator
newTag: 0.0.1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
capabilities: Basic Install
categories: |
Modernization & Migration,Developer Tools,Monitoring,Integration & Delivery
containerImage: quay.io/pelorus/pelorus-operator:0.0.1
description: |
Tool that helps IT organizations measure their impact on the overall performance of their organization
operatorframework.io/suggested-namespace: pelorus
Expand Down
32 changes: 16 additions & 16 deletions pelorus-operator/config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,6 @@ rules:
resources:
- "clusterrolebindings"
- "clusterroles"
- verbs:
- "*"
apiGroups:
- ""
resources:
- "configmaps"
- "secrets"
- "serviceaccounts"
- "services"
- verbs:
- "*"
apiGroups:
- "rbac.authorization.k8s.io"
resources:
- "rolebindings"
- "roles"
- verbs:
- "*"
apiGroups:
Expand Down Expand Up @@ -102,5 +86,21 @@ rules:
- "route.openshift.io"
resources:
- "routes"
- verbs:
- "*"
apiGroups:
- ""
resources:
- "configmaps"
- "secrets"
- "serviceaccounts"
- "services"
- verbs:
- "*"
apiGroups:
- "rbac.authorization.k8s.io"
resources:
- "rolebindings"
- "roles"

#+kubebuilder:scaffold:rules
2 changes: 1 addition & 1 deletion pelorus-operator/helm-charts/pelorus/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ dependencies:
repository: file://./subcharts/exporters
version: 2.0.4
digest: sha256:76d6f1ef53a7d8586a7d04dac9932b82460dcf135e48901741f510b401b906c3
generated: "2022-12-16T16:10:07.264461881+01:00"
generated: "2022-12-19T12:26:16.845346124+01:00"
50 changes: 27 additions & 23 deletions scripts/create_pelorus_operator
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#

OPERATOR_PROJECT_NAME=pelorus-operator
OPERATOR_ORG_NAME=migtools
OPERATOR_ORG_NAME=pelorus
OPERATOR_PROJECT_DOMAIN=pelorus.konveyor.io

# Get the full absolute path to the script. Needed while calling the script
Expand All @@ -31,9 +31,6 @@ DEFAULT_PELORUS_CHARTS_DIR="${SCRIPT_DIR}/${DEFAULT_PELORUS_CHARTS_SUBDIR}/"
DEFAULT_PELORUS_OPERATOR_DIR="${SCRIPT_DIR}/../pelorus-operator/"
DEFAULT_PELORUS_OPERATOR_PATCHES_DIR="${SCRIPT_DIR}/pelorus-operator-patches/"

# Needed for symlink inside pelorus-operator folder
DEFAULT_OPERATOR_HELM_CHART_SUBDIR="helm-charts/pelorus"

function print_help() {
printf "\nUsage: %s [OPTION]\n\n" "$0"
printf "\tStartup:\n"
Expand All @@ -42,17 +39,19 @@ function print_help() {
printf "\t -s\tpath to source pelorus helm charts folder, default: %s\n" "${DEFAULT_PELORUS_CHARTS_DIR}"
printf "\t -d\tpath to EMPTY destination folder, default: %s\n" "${DEFAULT_PELORUS_OPERATOR_DIR}"
printf "\t -p\tpath to DIR with operator patches to be applied, default: %s\n" "${DEFAULT_PELORUS_OPERATOR_PATCHES_DIR}"
printf "\t -v\toperator version to be used in a format x.y.z. If not set z+1 is used.\n"
exit 0
}

### Options
OPTIND=1
while getopts "s:d:p:h?" option; do
while getopts "s:d:p:h?v:" option; do
case "$option" in
h|\?) print_help;;
s) source_dir=$OPTARG;;
d) destination_dir=$OPTARG;;
p) patches_dir=$OPTARG;;
v) operator_ver=$OPTARG;;
esac
done

Expand Down Expand Up @@ -100,23 +99,19 @@ pushd "${destination_dir}" || exit 2
echo "INFO: Creating api"
operator-sdk create api --helm-chart="${source_dir}" || exit 2

# TBD: The symlink is not working. Manager do not contain any charts if they are symlinked
# We do want to have symlink to original helm-charts instead of direct copy,
# but ONLY when the pelorus-operator is within pelorus git repository, otherwise leave the copied version
# The check assumes the git pelorus charts are one level up from the pelorus-operator folder
# if git remote -v | grep \/pelorus.git; then
# [ -d "${DEFAULT_OPERATOR_HELM_CHART_SUBDIR}" ] && [ -d "../charts/pelorus" ] && echo "Removing ${DEFAULT_OPERATOR_HELM_CHART_SUBDIR} directory" && rm -rf "${DEFAULT_OPERATOR_HELM_CHART_SUBDIR}"
# pushd helm-charts || exit 2
# echo "Creating symlink from helm-charts/pelorus to directory"
# ln -s ../"${DEFAULT_PELORUS_CHARTS_SUBDIR}" ./pelorus
# popd || exit 2
# fi

# Correct operator version, to be latest +1
OPERATOR_VERSION=$(curl -H "Authorization: Bearer XYZ" -X GET "https://quay.io/api/v1/repository/${OPERATOR_ORG_NAME}/${OPERATOR_PROJECT_NAME}/tag/" | jq .tags[].name | head -1 | sed -e 's|\"||g')
echo "INFO: Current operator version: ${OPERATOR_VERSION}"
NEW_OPERATOR_VERSION=$(echo ${OPERATOR_VERSION} | awk -F. -v OFS=. '{$NF += 1 ; print}')
echo "INFO: New operator version: ${NEW_OPERATOR_VERSION}"
if [ -z ${operator_ver+x} ]; then
destination_dir="${DEFAULT_PELORUS_OPERATOR_DIR}"
# Correct operator version, to be latest +1
OPERATOR_VERSION=$(curl -H "Authorization: Bearer XYZ" -X GET "https://quay.io/api/v1/repository/${OPERATOR_ORG_NAME}/${OPERATOR_PROJECT_NAME}/tag/" | jq .tags[].name | head -1 | sed -e 's|\"||g')
echo "INFO: Current operator version: ${OPERATOR_VERSION}"
NEW_OPERATOR_VERSION=$(echo "${OPERATOR_VERSION}" | awk -F. -v OFS=. '{$NF += 1 ; print}')
if [ "$NEW_OPERATOR_VERSION" -eq "1" ]; then
NEW_OPERATOR_VERSION=0.0.1
fi
else
NEW_OPERATOR_VERSION="${operator_ver}"
fi

sed -i "s/VERSION ?= 0.0.1/VERSION ?= ${NEW_OPERATOR_VERSION}/g" Makefile || exit 2

# Correct IMAGE_TAG_BASE
Expand All @@ -142,6 +137,15 @@ elif [ "$(ls -A "${patches_dir}"/*.diff 2>/dev/null)" ]; then
fi

pushd "${destination_dir}" || exit 2

# Set proper value for the 'metadata.annotations.containerImage'
# We first patch the config/manifests/bases/pelorus-operator.clusterserviceversion.yaml
# with "containerImage: placeholder", because we don't know which ORG the image will be
# pushed to and in this step we set correct containerImage metadata.
OPERATOR_RESULTING_IMG="quay.io/${OPERATOR_ORG_NAME}/${OPERATOR_PROJECT_NAME}:${NEW_OPERATOR_VERSION}"
echo "INFO: Operator Image containerImage: ${OPERATOR_RESULTING_IMG}"
sed -i "s#^ containerImage: placeholder# containerImage: ${OPERATOR_RESULTING_IMG}#g" config/manifests/bases/pelorus-operator.clusterserviceversion.yaml || exit 2

echo "INFO: Executing make bundle"
make bundle
popd || exit 2
Expand Down Expand Up @@ -171,6 +175,6 @@ echo " # make bundle-build"
echo " # make bundle-push"
echo " # # Log in to your cluster or export KUBECONFIG"
echo " # # Deploy bundle, e.g. version v${NEW_OPERATOR_VERSION} in the pelorus namespace"
echo " # operator-sdk run bundle quay.io/migtools/pelorus-operator-bundle:v${NEW_OPERATOR_VERSION} --namespace pelorus"
echo " # operator-sdk run bundle quay.io/${OPERATOR_ORG_NAME}/pelorus-operator-bundle:v${NEW_OPERATOR_VERSION} --namespace pelorus"
echo " # # Create pelorus instance from example in the pelorus namespace"
echo " # oc apply -f pelorus-operator/config/samples/charts_v1alpha1_pelorus.yaml -n pelorus"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- config/manifests/bases/pelorus-operator.clusterserviceversion.yaml.original 2022-12-15 17:01:35.384242008 +0100
+++ config/manifests/bases/pelorus-operator.clusterserviceversion.yaml 2022-12-15 17:01:46.425296201 +0100
@@ -4,39 +4,110 @@
@@ -4,39 +4,111 @@
annotations:
alm-examples: '[]'
capabilities: Basic Install
Expand All @@ -11,6 +11,7 @@
+ operatorframework.io/suggested-namespace: pelorus
+ repository: https://github.com/konveyor/pelorus/
+ support: Pelorus Community
+ containerImage: placeholder
name: pelorus-operator.v0.0.0
namespace: placeholder
spec:
Expand Down
7 changes: 4 additions & 3 deletions scripts/pelorus-operator-patches/07_spec_description.diff
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- config/crd/bases/charts.pelorus.konveyor.io_pelorus.yaml.original 2022-12-16 11:41:22.683297131 +0100
+++ config/crd/bases/charts.pelorus.konveyor.io_pelorus.yaml 2022-12-16 11:40:22.725983634 +0100
@@ -15,29 +15,76 @@
--- config/crd/bases/charts.pelorus.konveyor.io_pelorus.yaml.original 2022-12-16 20:39:18.630409481 +0100
+++ config/crd/bases/charts.pelorus.konveyor.io_pelorus.yaml 2022-12-16 20:39:03.674340069 +0100
@@ -15,29 +15,77 @@
- name: v1alpha1
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -58,6 +58,7 @@
+ enabled: < won't be created if set to false >
+ exporter_type: < deploytime, committime, failure >
+ type: object
+ x-kubernetes-preserve-unknown-fields: true
+ prometheus_retention:
+ description: >-
+ Prometheus Retention time. More information:
Expand Down

0 comments on commit 632446a

Please sign in to comment.