From 16e5b94a748940c5116066d41e662d2b9cbc531c Mon Sep 17 00:00:00 2001 From: Nikhil-Ladha Date: Mon, 4 Mar 2024 17:42:04 +0530 Subject: [PATCH] Add rook bundle to ocs-operator catalog Add rook bundle to ocs-operator-catalog and update the relevant script files to inlcude the rook bundle image name and add rook bundle deployment script Signed-off-by: Nikhil-Ladha --- .gitignore | 1 + Makefile | 4 ++++ catalog/index.yaml | 11 +++++++++++ deploy/deploy-with-olm.yaml | 11 +++++++++++ hack/build-operator-catalog.sh | 1 + hack/common.sh | 1 + hack/install-rook.sh | 19 +++++++++++++++++++ pkg/deploy-manager/subscription.go | 16 +++++++++++++++- 8 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 hack/install-rook.sh diff --git a/.gitignore b/.gitignore index ac95e3bb2e..f690474226 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,7 @@ bin catalog/ocs-bundle.yaml catalog/noobaa-bundle.yaml +catalog/rook-ceph-bundle.yaml tools/csv-merger/csv-merger tools/csv-checksum/csv-checksum diff --git a/Makefile b/Makefile index 5f76fe3e12..3e9af0e720 100644 --- a/Makefile +++ b/Makefile @@ -187,3 +187,7 @@ install-noobaa: operator-sdk install-ocs: operator-sdk @echo "Installing ocs operator" hack/install-ocs.sh + +install-rook: operator-sdk + @echo "Installing rook-ceph operator" + hack/install-rook.sh diff --git a/catalog/index.yaml b/catalog/index.yaml index 5032f9ea80..b46613ac0d 100644 --- a/catalog/index.yaml +++ b/catalog/index.yaml @@ -9,6 +9,17 @@ name: alpha entries: - name: ocs-operator.v4.15.0 +--- +defaultChannel: alpha +name: rook-ceph-operator +schema: olm.package +--- +schema: olm.channel +package: rook-ceph-operator +name: alpha +entries: + - name: rook-ceph-operator.v4.15.0 + --- defaultChannel: alpha name: noobaa-operator diff --git a/deploy/deploy-with-olm.yaml b/deploy/deploy-with-olm.yaml index f385a24af4..8f897be1b2 100644 --- a/deploy/deploy-with-olm.yaml +++ b/deploy/deploy-with-olm.yaml @@ -51,3 +51,14 @@ spec: name: noobaa-operator source: ocs-catalogsource sourceNamespace: openshift-marketplace +--- +apiVersion: operators.coreos.com/v1alpha1 +kind: Subscription +metadata: + name: rook-subscription + namespace: openshift-storage +spec: + channel: alpha + name: rook-ceph-operator + source: ocs-catalogsource + sourceNamespace: openshift-marketplace diff --git a/hack/build-operator-catalog.sh b/hack/build-operator-catalog.sh index b16a4772f9..3b6c1c5841 100755 --- a/hack/build-operator-catalog.sh +++ b/hack/build-operator-catalog.sh @@ -12,6 +12,7 @@ echo "Run '${IMAGE_BUILD_CMD} push ${BUNDLE_FULL_IMAGE_NAME}'" echo ${OPM} render --output=yaml "${BUNDLE_FULL_IMAGE_NAME}" > catalog/ocs-bundle.yaml ${OPM} render --output=yaml ${NOOBAA_BUNDLE_FULL_IMAGE_NAME} > catalog/noobaa-bundle.yaml +${OPM} render --output=yaml ${ROOK_BUNDLE_FULL_IMAGE_NAME} > catalog/rook-ceph-bundle.yaml ${OPM} validate catalog ${OPM} generate dockerfile catalog diff --git a/hack/common.sh b/hack/common.sh index da52b53d65..31f3ee2a0c 100644 --- a/hack/common.sh +++ b/hack/common.sh @@ -86,6 +86,7 @@ METRICS_EXPORTER_FULL_IMAGE_NAME="${METRICS_EXPORTER_FULL_IMAGE_NAME:-${DEFAULT_ UX_BACKEND_OAUTH_FULL_IMAGE_NAME="${UX_BACKEND_OAUTH_FULL_IMAGE_NAME:-${DEFAULT_UX_BACKEND_OAUTH_FULL_IMAGE_NAME}}" NOOBAA_BUNDLE_FULL_IMAGE_NAME="quay.io/noobaa/noobaa-operator-bundle:master-20231217" +ROOK_BUNDLE_FULL_IMAGE_NAME="quay.io/ocs-dev/rook-ceph-operator-bundle:latest" OCS_OPERATOR_INSTALL="${OCS_OPERATOR_INSTALL:-false}" OCS_CLUSTER_UNINSTALL="${OCS_CLUSTER_UNINSTALL:-false}" diff --git a/hack/install-rook.sh b/hack/install-rook.sh new file mode 100644 index 0000000000..f67169f96f --- /dev/null +++ b/hack/install-rook.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -o nounset +set -o errexit +set -o pipefail + +source hack/common.sh + +NAMESPACE=$(oc get ns "$INSTALL_NAMESPACE" -o jsonpath="{.metadata.name}" 2>/dev/null || true) +if [[ -n "$NAMESPACE" ]]; then + echo "Namespace \"$NAMESPACE\" exists" +else + echo "Namespace \"$INSTALL_NAMESPACE\" does not exist: creating it" + oc create ns "$INSTALL_NAMESPACE" +fi + +"$OPERATOR_SDK" run bundle "$ROOK_BUNDLE_FULL_IMAGE_NAME" --timeout=10m --security-context-config restricted -n "$INSTALL_NAMESPACE" + +oc wait --timeout=5m --for condition=Available -n "$INSTALL_NAMESPACE" deployment rook-ceph-operator diff --git a/pkg/deploy-manager/subscription.go b/pkg/deploy-manager/subscription.go index e946b4bcf0..2cd79bbc81 100644 --- a/pkg/deploy-manager/subscription.go +++ b/pkg/deploy-manager/subscription.go @@ -163,6 +163,20 @@ func (t *DeployManager) generateClusterObjects(ocsCatalogImage string, subscript } ocsSubscription.SetGroupVersionKind(schema.GroupVersionKind{Group: v1alpha1.SchemeGroupVersion.Group, Kind: "Subscription", Version: v1alpha1.SchemeGroupVersion.Version}) + rookSubscription := v1alpha1.Subscription{ + ObjectMeta: metav1.ObjectMeta{ + Name: "rook-subscription", + Namespace: InstallNamespace, + }, + Spec: &v1alpha1.SubscriptionSpec{ + Channel: subscriptionChannel, + Package: "rook-ceph-operator", + CatalogSource: "ocs-catalogsource", + CatalogSourceNamespace: marketplaceNamespace, + }, + } + rookSubscription.SetGroupVersionKind(schema.GroupVersionKind{Group: v1alpha1.SchemeGroupVersion.Group, Kind: "Subscription", Version: v1alpha1.SchemeGroupVersion.Version}) + noobaSubscription := v1alpha1.Subscription{ ObjectMeta: metav1.ObjectMeta{ Name: "nooba-subscription", @@ -177,7 +191,7 @@ func (t *DeployManager) generateClusterObjects(ocsCatalogImage string, subscript } noobaSubscription.SetGroupVersionKind(schema.GroupVersionKind{Group: v1alpha1.SchemeGroupVersion.Group, Kind: "Subscription", Version: v1alpha1.SchemeGroupVersion.Version}) - co.subscriptions = append(co.subscriptions, ocsSubscription, noobaSubscription) + co.subscriptions = append(co.subscriptions, ocsSubscription, rookSubscription, noobaSubscription) return co }