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

[OLM] Fix operator UI and add new fields for operator #902

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 15 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
jobs:
MikeEdgar marked this conversation as resolved.
Show resolved Hide resolved
build-api:
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -32,6 +37,8 @@ jobs:

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host

- name: Build and Test
env:
Expand All @@ -48,7 +55,13 @@ jobs:
#
mvn verify -P container-image -B --no-transfer-progress \
-Dquarkus.package.write-transformed-bytecode-to-build-output=true \
-Dquarkus.docker.buildx.platform=linux/amd64,linux/arm64
-Dquarkus.docker.buildx.platform=linux/amd64,linux/arm64 \
-Dquarkus.container-image.registry="localhost:5000" \
-Dquarkus.container-image.push=true

- name: Modify CSV Annotation
run: |
./operator/bin/modify-bundle-metadata.sh

- name: Build Operator Bundle Image
uses: docker/build-push-action@v6
Expand All @@ -68,7 +81,7 @@ jobs:
sudo cp -v opm /usr/bin/
rm -vf opm
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | tr '[:upper:]' '[:lower:]')
operator/bin/generate-catalog.sh ${VERSION}
operator/bin/generate-catalog.sh ${VERSION}

- name: Build Operator Catalog Image
uses: docker/build-push-action@v6
Expand Down
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ IMAGE_GROUP ?= streamshub
VERSION = $(shell mvn help:evaluate -Dexpression=project.version -q -DforceStdout | tr '[:upper:]' '[:lower:]')

CONSOLE_API_IMAGE ?= $(IMAGE_REGISTRY)/$(IMAGE_GROUP)/console-api:$(VERSION)
CONSOLE_UI_IMAGE ?= $(IMAGE_REGISTRY)/$(IMAGE_GROUP)/console-ui:$(VERSION)

CONSOLE_OPERATOR_IMAGE ?= $(IMAGE_REGISTRY)/$(IMAGE_GROUP)/console-operator:$(VERSION)
CONSOLE_OPERATOR_BUNDLE_IMAGE ?= $(IMAGE_REGISTRY)/$(IMAGE_GROUP)/console-operator-bundle:$(VERSION)
CONSOLE_OPERATOR_CATALOG_IMAGE ?= $(IMAGE_REGISTRY)/$(IMAGE_GROUP)/console-operator-catalog:$(VERSION)
CONSOLE_UI_IMAGE ?= $(IMAGE_REGISTRY)/$(IMAGE_GROUP)/console-ui:$(VERSION)

CONTAINER_RUNTIME ?= $(shell which podman || which docker)
ARCH ?= linux/amd64
SKIP_RANGE ?= ">=1.0.0 <1.0.3"

CONSOLE_UI_NEXTAUTH_SECRET ?= $(shell openssl rand -base64 32)
CONSOLE_METRICS_PROMETHEUS_URL ?=
CONTAINER_RUNTIME ?= $(shell which podman || which docker)

container-image-api:
mvn package -am -pl api -Pcontainer-image -DskipTests -Dquarkus.container-image.image=$(CONSOLE_API_IMAGE)
Expand All @@ -25,9 +29,10 @@ container-image-api-push: container-image-api

container-image-operator:
mvn package -am -pl operator -Pcontainer-image -DskipTests -Dquarkus.container-image.image=$(CONSOLE_OPERATOR_IMAGE)
operator/bin/modify-bundle-metadata.sh
operator/bin/generate-catalog.sh $(VERSION)
$(CONTAINER_RUNTIME) build -t $(CONSOLE_OPERATOR_BUNDLE_IMAGE) -f operator/target/bundle/console-operator/bundle.Dockerfile
$(CONTAINER_RUNTIME) build -t $(CONSOLE_OPERATOR_CATALOG_IMAGE) -f operator/target/catalog.Dockerfile
$(CONTAINER_RUNTIME) build --platform=$(ARCH) -t $(CONSOLE_OPERATOR_BUNDLE_IMAGE) -f operator/target/bundle/console-operator/bundle.Dockerfile
$(CONTAINER_RUNTIME) build --platform=$(ARCH) -t $(CONSOLE_OPERATOR_CATALOG_IMAGE) -f operator/target/catalog.Dockerfile

container-image-operator-push: container-image-operator
$(CONTAINER_RUNTIME) push $(CONSOLE_OPERATOR_IMAGE)
Expand Down
21 changes: 21 additions & 0 deletions operator/bin/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

SCRIPT_PATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)"

BUNDLE_PATH=${SCRIPT_PATH}/../target/bundle/console-operator/
CSV_FILE_PATH=${BUNDLE_PATH}/manifests/console-operator.clusterserviceversion.yaml
CATALOG_PATH=${SCRIPT_PATH}/../target/catalog

YQ="$(which yq 2>/dev/null)" || :

if [ "${YQ}" == "" ] ; then
echo -e "'yq' is not installed, please visit https://github.com/mikefarah/yq for more info"
exit 1
fi

SKOPEO="$(which skopeo 2>/dev/null)" || :

if [ "${SKOPEO}" == "" ] ; then
echo "'skopeo' is not installed, please visit https://github.com/containers/skopeo/blob/main/install.md for more info"
exit 1
fi
10 changes: 6 additions & 4 deletions operator/bin/generate-catalog.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/bin/bash

SCRIPT_PATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)"

source ${SCRIPT_PATH}/common.sh
export VERSION="${1}"

CATALOG_PATH=${SCRIPT_PATH}/../target/catalog
echo "[INFO] Generate catalog"

rm -rvf ${CATALOG_PATH} ${CATALOG_PATH}.Dockerfile
mkdir -p ${CATALOG_PATH}

opm generate dockerfile ${CATALOG_PATH}
opm init console-operator --default-channel=alpha --output=yaml > ${CATALOG_PATH}/operator.yaml
opm render operator/target/bundle/console-operator/ --output=yaml >> ${CATALOG_PATH}/operator.yaml
opm render ${BUNDLE_PATH} --output=yaml >> ${CATALOG_PATH}/operator.yaml

cat << EOF >> ${CATALOG_PATH}/operator.yaml
---
schema: olm.channel
Expand All @@ -20,4 +22,4 @@ entries:
- name: console-operator.v${VERSION}
EOF

opm validate ${CATALOG_PATH}
opm validate ${CATALOG_PATH}
51 changes: 51 additions & 0 deletions operator/bin/modify-bundle-metadata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

SCRIPT_PATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)"
source ${SCRIPT_PATH}/common.sh

ARCH=linux/amd64
MikeEdgar marked this conversation as resolved.
Show resolved Hide resolved
SKIP_RANGE=""
OPERATOR_NAME="console-operator"

for ARGUMENT in "$@"
do
KEY=$(echo "$ARGUMENT" | sed 's/=\(.*\)//')
VALUE=$(echo "$ARGUMENT" | sed 's/^[^=]*=//')

case "$KEY" in
ARCH) ARCH=${VALUE} ;;
SKIP_RANGE) SKIP_RANGE=${VALUE};;
OPERATOR_NAME) OPERATOR_NAME=${VALUE};;
*)
esac
done

echo "[INFO] Modify values and replace placeholders in ${CSV_FILE_PATH}"

yq_image_expression=".spec.install.spec.deployments[0] | (select (.name ==\"${OPERATOR_NAME}\")).spec.template.spec.containers[].image"

full_image=$(${YQ} eval "${yq_image_expression}" "${CSV_FILE_PATH}")
echo "[DEBUG] Original image name = ${full_image}"

image_name=$(echo "${full_image}" | cut -d':' -f1)
digest=$(${SKOPEO} inspect --tls-verify=false --override-os=linux --format "{{ .Digest }}" "docker://${full_image}")
image_with_digest="${image_name}@${digest}"

# Create relatedImages section
${YQ} eval -o yaml -i ".spec.relatedImages = null" "${CSV_FILE_PATH}"

# Add operator image
${YQ} eval -o yaml -i ".spec.relatedImages += [{\"name\": \"${OPERATOR_NAME}\", \"image\": \"${image_with_digest}\"}]" "${CSV_FILE_PATH}";
echo "[DEBUG] Setting container image = ${image_with_digest}"
${YQ} eval -o yaml -i ".metadata.annotations.containerImage = \"${image_with_digest}\"" "${CSV_FILE_PATH}"

# Add current createdAt time
curr_time_date=$(date +'%Y-%m-%d %H:%M:%S')
echo "[DEBUG] Setting createdAt = ${curr_time_date}"
${YQ} eval -o yaml -i ".metadata.annotations.createdAt = \"${curr_time_date}\"" "${CSV_FILE_PATH}"

# Add skipRange if present
if [[ -n "$SKIP_RANGE" ]]; then
echo "[DEBUG] Setting skipRange = \"${SKIP_RANGE}\""
${YQ} eval -o yaml -i ".metadata.annotations.[\"olm.skipRange\"] = \"${SKIP_RANGE}\"" "${CSV_FILE_PATH}"
fi
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import io.javaoperatorsdk.operator.api.reconciler.dependent.Dependent;
import io.javaoperatorsdk.operator.processing.event.source.EventSource;
import io.quarkiverse.operatorsdk.annotations.CSVMetadata;
import io.quarkiverse.operatorsdk.annotations.CSVMetadata.Annotations;
import io.quarkiverse.operatorsdk.annotations.CSVMetadata.Annotations.Annotation;
import io.quarkiverse.operatorsdk.annotations.CSVMetadata.InstallMode;
import io.quarkiverse.operatorsdk.annotations.CSVMetadata.Provider;

Expand Down Expand Up @@ -117,6 +119,20 @@
})
@CSVMetadata(
provider = @Provider(name = "StreamsHub", url = "https://github.com/streamshub"),
annotations = @Annotations(
containerImage = "placeholder",
repository = "https://github.com/streamshub/console",
capabilities = "Basic Install",
categories = "Streaming & Messaging",
certified = true,
skipRange = "placeholder",
others = {
@Annotation(name = "features.operators.openshift.io/fips-compliant", value = "true"),
@Annotation(name = "features.operators.openshift.io/disconnected", value = "true"),
@Annotation(name = "features.operators.openshift.io/proxy-aware", value = "true"),
@Annotation(name = "createdAt", value = "placeholder"),
@Annotation(name = "support", value = "Streamshub")
}),
description = "StreamsHub console provides a user interface for managing and monitoring your streaming resources",
installModes = {
@InstallMode(type = "AllNamespaces", supported = true),
Expand Down