Skip to content

Commit

Permalink
[OLM] Operator name change (#1230)
Browse files Browse the repository at this point in the history
* Change operator name to streamshub-console-operator
* Modified install olm resources
* Fix container image name to console-operator
* Fix playwright catalog wait
* Remove x.y.z version of operator in release artifacts

---------

Signed-off-by: jkalinic <[email protected]>
  • Loading branch information
jankalinic authored Nov 23, 2024
1 parent 22b8580 commit f82e781
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/playwright-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
./install/operator-olm/010-CatalogSource-console-operator-catalog.yaml \
| kubectl apply -n olm -f -
kubectl wait catalogsource/console-operator-catalog -n olm \
kubectl wait catalogsource/streamshub-console-catalog -n olm \
--for=jsonpath='{.status.connectionState.lastObservedState}'=READY \
--timeout=180s
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
export -f wait_operator
timeout 300s bash -c 'wait_operator "strimzi-kafka-operator"'
timeout 300s bash -c 'wait_operator "console-operator"'
timeout 300s bash -c 'wait_operator "streamshub-console-operator"'
# replace with resources in docs PR
- name: Deploy Kafka Cluster & Console
Expand Down Expand Up @@ -248,7 +248,7 @@ jobs:
mkdir ./resources
kubectl get all,catalogsources,operatorgroups -n olm -o yaml > ./resources/olm.yaml
kubectl get all,subscriptions,csv,operatorgroups,installplans -n operators -o yaml > ./resources/operators.yaml
kubectl logs -n operators -l app.kubernetes.io/name=console-operator --all-containers=true --tail -1 > ./resources/console-operator-logs.txt
kubectl logs -n operators -l app.kubernetes.io/name=streamshub-console-operator --all-containers=true --tail -1 > ./resources/streamshub-console-operator-logs.txt
kubectl get all -n $TARGET_NAMESPACE -o yaml > ./resources/$TARGET_NAMESPACE.yaml
kubectl logs -n ${TARGET_NAMESPACE} -l app.kubernetes.io/instance=example-console-deployment --all-containers=true --tail -1 > ./resources/$TARGET_NAMESPACE-console-logs.txt
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ jobs:
cat ${RELEASE_K8S_PATH}/consoles.console.streamshub.github.com-v1.yml \
${RELEASE_K8S_PATH}/kubernetes.yml \
> target/console-operator-${{ steps.metadata.outputs.current-version }}.yaml
> target/streamshub-console-operator.yaml
- name: Push Release Tag
run: |
Expand All @@ -151,4 +151,4 @@ jobs:
tag: ${{ steps.metadata.outputs.current-version }}
allow_override: true
gzip: false
files: target/console-operator-${{ steps.metadata.outputs.current-version }}.yaml
files: target/streamshub-console-operator.yaml
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ SKIP_RANGE ?= ">=1.0.0 <1.0.3"

CONSOLE_UI_NEXTAUTH_SECRET ?= $(shell openssl rand -base64 32)

# This helps to build CSV using Quarkus with correct image tags in lowercase "-snapshot" instead of "-SNAPSHOT" (default project pom value)
# Without this export, UI and API images could not be pulled from registry during the deployment of Console instance
export QUARKUS_CONTAINER_IMAGE_TAG=${VERSION}
export QUARKUS_KUBERNETES_VERSION=${VERSION}

container-image-api:
mvn package -am -pl api -Pcontainer-image -DskipTests -Dquarkus.container-image.image=$(CONSOLE_API_IMAGE)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ spec:
```

### Deploy the operator directly
Deploying the operator without the use of OLM requires applying the component Kubernetes resources for the operator directly. These resources are bundled and attached to each StreamsHub Console release. The latest release can be found [here](https://github.com/streamshub/console/releases/latest). The resource file is named `console-operator-x.y.z.yaml` where `x.y.z` is the released version.
Deploying the operator without the use of OLM requires applying the component Kubernetes resources for the operator directly. These resources are bundled and attached to each StreamsHub Console release. The latest release can be found [here](https://github.com/streamshub/console/releases/latest). The resource file is named `streamshub-console-operator.yaml`.

This example will create the operator's resources in the `default` namespace. Modify the `NAMESPACE` variable according to your needs and set `VERSION` to the [latest release](https://github.com/streamshub/console/releases/latest).
```
export NAMESPACE=default
export VERSION=0.3.3
curl -sL https://github.com/streamshub/console/releases/download/${VERSION}/console-operator-${VERSION}.yaml \
curl -sL https://github.com/streamshub/console/releases/download/${VERSION}/streamshub-console-operator.yaml \
| envsubst \
| kubectl apply -n ${NAMESPACE} -f -
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: console-operator
name: streamshub-operators
spec:
targetNamespaces: []
upgradeStrategy: Default
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: console-operator-catalog
name: streamshub-console-catalog
spec:
displayName: StreamsHub
image: quay.io/streamshub/console-operator-catalog:latest
Expand Down
6 changes: 3 additions & 3 deletions install/operator-olm/020-Subscription-console-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: console-operator
name: streamshub-console-sub
spec:
name: console-operator
name: streamshub-console-operator
channel: alpha
source: console-operator-catalog
source: streamshub-console-catalog
sourceNamespace: ${NAMESPACE}
5 changes: 5 additions & 0 deletions operator/bin/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ 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
# Operator naming
ORIGINAL_OPERATOR_NAME="console-operator"
OPERATOR_NAME="streamshub-console-operator"
OPERATOR_INSTANCE_NAME="${OPERATOR_NAME}-v${VERSION}"
OPERATOR_CSV_NAME="${OPERATOR_NAME}.v${VERSION}"

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

Expand Down
14 changes: 10 additions & 4 deletions operator/bin/generate-catalog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ 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 init ${OPERATOR_NAME} --default-channel=alpha --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
package: console-operator
package: ${OPERATOR_NAME}
name: alpha
entries:
- name: console-operator.v${VERSION}
- name: ${OPERATOR_CSV_NAME}
EOF

opm validate ${CATALOG_PATH}
# Rename package names
${YQ} eval -o yaml -i ". |= select(.package == \"${ORIGINAL_OPERATOR_NAME}\").package = \"${OPERATOR_NAME}\"" "${CATALOG_PATH}/operator.yaml"
${YQ} eval -o yaml -i "(.properties[] | select(.value.packageName == \"${ORIGINAL_OPERATOR_NAME}\") | .value.packageName) = \"${OPERATOR_NAME}\"" "${CATALOG_PATH}/operator.yaml"

opm validate ${CATALOG_PATH}

echo "[DEBUG] Catalog generated"
17 changes: 14 additions & 3 deletions operator/bin/modify-bundle-metadata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ SCRIPT_PATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)"
source ${SCRIPT_PATH}/common.sh

SKIP_RANGE=""
OPERATOR_NAME="console-operator"

for ARGUMENT in "$@"
do
Expand All @@ -13,7 +12,7 @@ do

case "$KEY" in
SKIP_RANGE) SKIP_RANGE=${VALUE};;
OPERATOR_NAME) OPERATOR_NAME=${VALUE};;
ORIGINAL_OPERATOR_NAME) ORIGINAL_OPERATOR_NAME=${VALUE};;
*)
esac
done
Expand All @@ -23,7 +22,7 @@ echo "[INFO] Modify values and replace placeholders in ${CSV_FILE_PATH}"
# Delete any namespaces set on the CSV deployment(s), possibly added by `quarkus.kubernetes.namespace`
${YQ} eval -o yaml -i 'del(.spec.install.spec.deployments[0].spec.template.metadata.namespace)' "${CSV_FILE_PATH}"

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

full_image=$(${YQ} eval "${yq_image_expression}" "${CSV_FILE_PATH}")
echo "[DEBUG] Original image name = ${full_image}"
Expand All @@ -45,6 +44,18 @@ curr_time_date="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
echo "[DEBUG] Setting createdAt = ${curr_time_date}"
${YQ} eval -o yaml -i ".metadata.annotations.createdAt = \"${curr_time_date}\"" "${CSV_FILE_PATH}"

# Change operator name
echo "[DEBUG] Renaming operator to ${OPERATOR_INSTANCE_NAME}"
${YQ} eval -o yaml -i ".metadata.name = \"${OPERATOR_CSV_NAME}\" | .metadata.name style=\"\"" "${CSV_FILE_PATH}"
${YQ} eval -o yaml -i ".spec.install.spec.deployments[0].name = \"${OPERATOR_INSTANCE_NAME}\"" "${CSV_FILE_PATH}"
${YQ} eval -o yaml -i ".spec.install.spec.deployments[0].spec.selector.matchLabels[\"app.kubernetes.io/name\"] = \"${OPERATOR_INSTANCE_NAME}\"" "${CSV_FILE_PATH}"
${YQ} eval -o yaml -i ".spec.install.spec.deployments[0].spec.template.metadata.labels[\"app.kubernetes.io/instance\"] = \"${OPERATOR_INSTANCE_NAME}\"" "${CSV_FILE_PATH}"
${YQ} eval -o yaml -i ".spec.install.spec.deployments[0].spec.template.metadata.labels[\"app.kubernetes.io/name\"] = \"${OPERATOR_INSTANCE_NAME}\"" "${CSV_FILE_PATH}"
${YQ} eval -o yaml -i ".spec.install.spec.deployments[0].spec.template.spec.containers[0].name = \"${OPERATOR_NAME}\"" "${CSV_FILE_PATH}"
# Change serviceAccountName as well
${YQ} eval -o yaml -i ".spec.install.spec.deployments[0].spec.template.spec.serviceAccountName = \"${OPERATOR_NAME}\"" "${CSV_FILE_PATH}"
${YQ} eval -o yaml -i ".spec.install.spec.clusterPermissions.[].serviceAccountName = \"${OPERATOR_NAME}\"" "${CSV_FILE_PATH}"

# Add skipRange if present
if [[ -n "$SKIP_RANGE" ]]; then
echo "[DEBUG] Setting skipRange = \"${SKIP_RANGE}\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
@ApplicationScoped
public class LeaderConfiguration extends LeaderElectionConfiguration {
public LeaderConfiguration() {
super("console-operator-lease");
super("streamshub-console-operator-lease");
}
}
6 changes: 3 additions & 3 deletions operator/src/main/kubernetes/kubernetes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ rules:
# The cluster operator needs to access and manage leases for leader election
- leases
resourceNames:
- console-operator-lease
- streamshub-console-operator-lease
verbs:
- get
- list
Expand Down Expand Up @@ -89,7 +89,7 @@ roleRef:
name: consolereconciler-additional-cluster-role
subjects:
- kind: ServiceAccount
name: console-operator
name: streamshub-console-operator
---
# Required in order to grant to console instances with OpenShift Cluster Monitoring integration
kind: ClusterRoleBinding
Expand All @@ -102,4 +102,4 @@ roleRef:
name: cluster-monitoring-view
subjects:
- kind: ServiceAccount
name: console-operator
name: streamshub-console-operator

0 comments on commit f82e781

Please sign in to comment.