From 61396c2508c4099da010fb7e1ae0b5b6e548dadd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Mac=C3=ADk?= Date: Fri, 14 Jun 2024 12:13:32 +0200 Subject: [PATCH] feat(RHIDP-2305): switch framework to RHDH v1.2 (#49) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pavel MacĂ­k --- Makefile | 6 +- ci-scripts/rhdh-setup/create_resource.sh | 5 +- ci-scripts/rhdh-setup/deploy.sh | 212 +++++++++--------- .../rhdh-setup/install-rhdh-catalog-source.sh | 2 +- .../helm/chart-values.image-override.yaml | 7 +- .../template/backstage/helm/chart-values.yaml | 7 +- .../olm/app-config.rhdh.backend-secret.yaml | 7 +- 7 files changed, 129 insertions(+), 117 deletions(-) diff --git a/Makefile b/Makefile index 323d659..c04261f 100644 --- a/Makefile +++ b/Makefile @@ -29,14 +29,14 @@ export RHDH_IMAGE_TAG ?= # RHDH Helm chart to deploy export RHDH_NAMESPACE ?= rhdh-performance -export RHDH_HELM_REPO ?= https://raw.githubusercontent.com/rhdh-bot/openshift-helm-charts/rhdh-1.1-rhel-9/installation +export RHDH_HELM_REPO ?= https://raw.githubusercontent.com/rhdh-bot/openshift-helm-charts/rhdh-1.2-rhel-9/installation export RHDH_HELM_CHART ?= redhat-developer-hub export RHDH_HELM_CHART_VERSION ?= export RHDH_HELM_RELEASE_NAME ?= rhdh # RHDH OLM subscription to deploy -export RHDH_OLM_INDEX_IMAGE ?= registry.redhat.io/redhat/redhat-operator-index:v$(shell oc version -o json | jq -r '.openshiftVersion' | sed -r -e "s,([0-9]+\.[0-9]+)\..+,\1,") -export RHDH_OLM_CHANNEL ?= fast-1.1 +export RHDH_OLM_INDEX_IMAGE ?= quay.io/rhdh/iib:1.2-v$(shell oc version -o json | jq -r '.openshiftVersion' | sed -r -e "s,([0-9]+\.[0-9]+)\..+,\1,")-$(shell oc version -o json | jq -r '.serverVersion.platform' | sed -r -e "s,linux/,," | sed -e 's,amd64,x86_64,') +export RHDH_OLM_CHANNEL ?= fast # RHDH horizontal scaling export RHDH_DEPLOYMENT_REPLICAS ?= 1 diff --git a/ci-scripts/rhdh-setup/create_resource.sh b/ci-scripts/rhdh-setup/create_resource.sh index 6ffda2c..ae1f5a8 100755 --- a/ci-scripts/rhdh-setup/create_resource.sh +++ b/ci-scripts/rhdh-setup/create_resource.sh @@ -106,8 +106,9 @@ clone_and_upload() { sleep 5 rhdh_token=$(curl -s -k "$(backstage_url)/api/auth/guest/refresh" | jq -r '.backstageIdentity.token') for filename in "${files[@]}"; do - e_count=$(yq eval '.metadata.name | capture(".*-(?[0-9]+)").value' "$filename" | tail -n 1) + e_count=$(yq eval '.metadata.name | capture(".*-(?P[0-9]+)").value' "$filename" | tail -n 1) upload_url="${GITHUB_REPO%.*}/blob/${tmp_branch}/$(basename "$filename")" + echo "Uploading entities from $upload_url" curl -k "$(backstage_url)/api/catalog/locations" -X POST -H 'Accept-Encoding: gzip, deflate, br' -H 'Authorization: Bearer '"$rhdh_token" -H 'Content-Type: application/json' --data-raw '{"type":"url","target":"'"${upload_url}"'"}' timeout_timestamp=$(date -d "300 seconds" "+%s") @@ -120,7 +121,7 @@ clone_and_upload() { if [[ 'api-*.yaml' == "${1}" ]]; then b_count=$(curl -s -k "$(backstage_url)/api/catalog/entity-facets?facet=kind" -H 'Content-Type: application/json' -H 'Authorization: Bearer '"$rhdh_token" | jq -r '.facets.kind[] | select(.value == "API")| .count'); fi if [[ $b_count -ge $e_count ]]; then break; fi fi - echo "Waiting for the entity count ${e_count}" + echo "Waiting for the entity count to be ${e_count} (current: ${b_count})" sleep 10s done done diff --git a/ci-scripts/rhdh-setup/deploy.sh b/ci-scripts/rhdh-setup/deploy.sh index 552cc45..8c06b02 100755 --- a/ci-scripts/rhdh-setup/deploy.sh +++ b/ci-scripts/rhdh-setup/deploy.sh @@ -36,12 +36,14 @@ export RHDH_IMAGE_REGISTRY=${RHDH_IMAGE_REGISTRY:-} export RHDH_IMAGE_REPO=${RHDH_IMAGE_REPO:-} export RHDH_IMAGE_TAG=${RHDH_IMAGE_TAG:-} -export RHDH_HELM_REPO=${RHDH_HELM_REPO:-https://raw.githubusercontent.com/rhdh-bot/openshift-helm-charts/rhdh-1.1-rhel-9/installation} +export RHDH_HELM_REPO=${RHDH_HELM_REPO:-https://raw.githubusercontent.com/rhdh-bot/openshift-helm-charts/rhdh-1.2-rhel-9/installation} export RHDH_HELM_CHART=${RHDH_HELM_CHART:-redhat-developer-hub} export RHDH_HELM_CHART_VERSION=${RHDH_HELM_CHART_VERSION:-} -export RHDH_OLM_INDEX_IMAGE="${RHDH_OLM_INDEX_IMAGE:-registry.redhat.io/redhat/redhat-operator-index:v$(oc version -o json | jq -r '.openshiftVersion' | sed -r -e "s#([0-9]+\.[0-9]+)\..+#\1#")}" -export RHDH_OLM_CHANNEL=${RHDH_OLM_CHANNEL:-fast-1.1} +OCP_VER="$(oc version -o json | jq -r '.openshiftVersion' | sed -r -e "s#([0-9]+\.[0-9]+)\..+#\1#")" +OCP_ARCH="$(oc version -o json | jq -r '.serverVersion.platform' | sed -r -e "s#linux/##" | sed -e 's#amd64#x86_64#')" +export RHDH_OLM_INDEX_IMAGE="${RHDH_OLM_INDEX_IMAGE:-quay.io/rhdh/iib:1.2-v${OCP_VER}-${OCP_ARCH}}" +export RHDH_OLM_CHANNEL=${RHDH_OLM_CHANNEL:-fast} export PRE_LOAD_DB="${PRE_LOAD_DB:-true}" export BACKSTAGE_USER_COUNT="${BACKSTAGE_USER_COUNT:-1}" @@ -100,26 +102,19 @@ wait_to_start() { wait_to_start_in_namespace "$RHDH_NAMESPACE" "$@" } -delete() { - echo "Remove RHDH with install method: $INSTALL_METHOD" - if ! $cli get ns "$RHDH_NAMESPACE" >/dev/null; then - echo "$RHDH_NAMESPACE namespace does not exit... Skipping. " - else - for cr in keycloakusers keycloakclients keycloakrealms keycloaks; do - for res in $($clin get "$cr.keycloak.org" -o name); do - $clin patch "$res" -p '{"metadata":{"finalizers":[]}}' --type=merge - $clin delete "$res" --wait - done - done - fi - if [ "$INSTALL_METHOD" == "helm" ]; then - helm uninstall "${RHDH_HELM_RELEASE_NAME}" --namespace "${RHDH_NAMESPACE}" - $clin delete pvc "data-${RHDH_HELM_RELEASE_NAME}-postgresql-0" --ignore-not-found=true - $cli delete ns "${RHDH_NAMESPACE}" --ignore-not-found=true --wait - helm repo remove "${repo_name}" || true - elif [ "$INSTALL_METHOD" == "olm" ]; then - delete_rhdh_with_olm +install() { + appurl=$(oc whoami --show-console) + export OPENSHIFT_APP_DOMAIN=${appurl#*.} + $cli create namespace "${RHDH_NAMESPACE}" --dry-run=client -o yaml | $cli apply -f - + keycloak_install + + if $PRE_LOAD_DB; then + create_groups + create_users fi + + backstage_install + setup_monitoring } keycloak_install() { @@ -141,6 +136,21 @@ keycloak_install() { envsubst