diff --git a/bin/install-argocd.sh b/bin/install-argocd.sh index 8ce3eabb..8efac6b7 100755 --- a/bin/install-argocd.sh +++ b/bin/install-argocd.sh @@ -1,25 +1,25 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="argocd" +SERVICE_NAME_DEFAULT="argocd" SERVICE_NAMESPACE="argocd" # Helm -HELM_REPO_NAME="bitnami" -HELM_REPO_URL="https://charts.bitnami.com/bitnami" +HELM_REPO_NAME_DEFAULT="bitnami" +HELM_REPO_URL_DEFAULT="https://charts.bitnami.com/bitnami" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${SERVICE_BASE_OVERRIDES:-$GENESTACK_BASE_DIR/base-helm-configs/$SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${SERVICE_CUSTOM_OVERRIDES:-$GENESTACK_OVERRIDES_DIR/helm-configs/$SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" @@ -29,20 +29,54 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() -# Base Override Files +# Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -57,8 +91,9 @@ else fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then - echo "Including overrides from config directory:" + echo "Including overrides from service config directory: $SERVICE_CUSTOM_OVERRIDES" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -66,21 +101,24 @@ if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then fi done else - echo "Warning: Config directory not found: $SERVICE_CUSTOM_OVERRIDES" + echo "Warning: Service overrides directory not found: $SERVICE_CUSTOM_OVERRIDES" fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update +# Collect all --set arguments, executing commands and quoting safely +set_args=() + helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME"/"$SERVICE_NAME" - --create-namespace --namespace="$SERVICE_NAMESPACE" --timeout 120m + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" + --namespace="$SERVICE_NAMESPACE" + --timeout 120m + --create-namespace "${overrides_args[@]}" + "${set_args[@]}" # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" diff --git a/bin/install-barbican.sh b/bin/install-barbican.sh index 64b6fba3..1b30d216 100755 --- a/bin/install-barbican.sh +++ b/bin/install-barbican.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) @@ -7,23 +7,23 @@ # Service # The service name is used for both the release name and the chart name. -SERVICE_NAME="barbican" +SERVICE_NAME_DEFAULT="barbican" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Define the Global Overrides directory used in the original script -GLOBAL_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" +GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" @@ -33,20 +33,55 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically. -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() -# Base Override Files: Check the standard base directory. +# Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -60,22 +95,24 @@ else echo "Warning: Base override directory not found: $SERVICE_BASE_OVERRIDES" fi -# Include Global Overrides -if [[ -d "$GLOBAL_OVERRIDES" ]]; then - echo "Including global overrides from directory: $GLOBAL_OVERRIDES" - for file in "$GLOBAL_OVERRIDES"/*.yaml; do +# Include all YAML files from the GLOBAL configuration directory +# NOTE: Files here override base settings and are applied before service-specific ones. +if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" + for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" overrides_args+=("-f" "$file") fi done else - echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then - echo "Including overrides from config directory:" + echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -83,15 +120,11 @@ if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then fi done else - echo "Warning: Config directory not found: $SERVICE_OVERRIDES" + echo "Warning: Service config directory not found: $SERVICE_CUSTOM_OVERRIDES" fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely set_args=( --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" @@ -106,7 +139,7 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME"/"$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -117,7 +150,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -127,5 +160,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" - +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-blazar.sh b/bin/install-blazar.sh index 6757e784..dd5fe3eb 100755 --- a/bin/install-blazar.sh +++ b/bin/install-blazar.sh @@ -1,28 +1,29 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="blazar" +# The service name is used for both the release name and the chart name. +SERVICE_NAME_DEFAULT="blazar" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Define the Global Overrides directory used in the original script -GLOBAL_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" +GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" @@ -32,20 +33,55 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically. -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() -# Base Override Files: Check the standard base directory. +# Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -59,22 +95,24 @@ else echo "Warning: Base override directory not found: $SERVICE_BASE_OVERRIDES" fi -# Include Global Overrides -if [[ -d "$GLOBAL_OVERRIDES" ]]; then - echo "Including global overrides from directory: $GLOBAL_OVERRIDES" - for file in "$GLOBAL_OVERRIDES"/*.yaml; do +# Include all YAML files from the GLOBAL configuration directory +# NOTE: Files here override base settings and are applied before service-specific ones. +if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" + for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" overrides_args+=("-f" "$file") fi done else - echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then - echo "Including overrides from config directory:" + echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -82,15 +120,11 @@ if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then fi done else - echo "Warning: Config directory not found: $SERVICE_CUSTOM_OVERRIDES" + echo "Warning: Service config directory not found: $SERVICE_CUSTOM_OVERRIDES" fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely set_args=( --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" @@ -106,7 +140,7 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -117,7 +151,8 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" + "$@" ) @@ -126,4 +161,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-ceilometer.sh b/bin/install-ceilometer.sh index 4b93d711..00872171 100755 --- a/bin/install-ceilometer.sh +++ b/bin/install-ceilometer.sh @@ -1,25 +1,27 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="ceilometer" +SERVICE_NAME_DEFAULT="ceilometer" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" + +# Define the Global Overrides directory used in the original script GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE @@ -30,20 +32,55 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -58,8 +95,9 @@ else fi # Include all YAML files from the GLOBAL configuration directory +# NOTE: Files here override base settings and are applied before service-specific ones. if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then - echo "Including overrides from global config directory:" + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -67,10 +105,11 @@ if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES_DIR" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -85,10 +124,6 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely set_args=( --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" @@ -114,7 +149,7 @@ rabbit://magnum:$(kubectl --namespace openstack get secret magnum-rabbitmq-passw helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -125,7 +160,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -135,4 +170,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-cinder.sh b/bin/install-cinder.sh index d7e76933..f99644e3 100755 --- a/bin/install-cinder.sh +++ b/bin/install-cinder.sh @@ -1,25 +1,27 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="cinder" +SERVICE_NAME_DEFAULT="cinder" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" + +# Define the Global Overrides directory used in the original script GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE @@ -30,20 +32,55 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -58,8 +95,9 @@ else fi # Include all YAML files from the GLOBAL configuration directory +# NOTE: Files here override base settings and are applied before service-specific ones. if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then - echo "Including overrides from global config directory:" + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -67,10 +105,11 @@ if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES_DIR" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -85,11 +124,9 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely +# NOTE: This array contains OpenStack-specific secret retrievals and MUST be updated +# with the necessary --set arguments for your target SERVICE_NAME_DEFAULT. set_args=( --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" --set "endpoints.identity.auth.cinder.password=$(kubectl --namespace openstack get secret cinder-admin -o jsonpath='{.data.password}' | base64 -d)" @@ -97,13 +134,14 @@ set_args=( --set "endpoints.oslo_db.auth.cinder.password=$(kubectl --namespace openstack get secret cinder-db-password -o jsonpath='{.data.password}' | base64 -d)" --set "endpoints.oslo_cache.auth.memcache_secret_key=$(kubectl --namespace openstack get secret os-memcached -o jsonpath='{.data.memcache_secret_key}' | base64 -d)" --set "conf.cinder.keystone_authtoken.memcache_secret_key=$(kubectl --namespace openstack get secret os-memcached -o jsonpath='{.data.memcache_secret_key}' | base64 -d)" + --set "conf.cinder.database.slave_connection=mysql+pymysql://cinder:$(kubectl --namespace openstack get secret cinder-db-password -o jsonpath='{.data.password}' | base64 -d)@mariadb-cluster-secondary.openstack.svc.cluster.local:3306/cinder" --set "endpoints.oslo_messaging.auth.admin.password=$(kubectl --namespace openstack get secret rabbitmq-default-user -o jsonpath='{.data.password}' | base64 -d)" --set "endpoints.oslo_messaging.auth.cinder.password=$(kubectl --namespace openstack get secret cinder-rabbitmq-password -o jsonpath='{.data.password}' | base64 -d)" ) helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -114,7 +152,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -124,4 +162,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-cloudkitty.sh b/bin/install-cloudkitty.sh index a205237f..f330255d 100755 --- a/bin/install-cloudkitty.sh +++ b/bin/install-cloudkitty.sh @@ -1,25 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="cloudkitty" +# The service name is used for both the release name and the chart name. +SERVICE_NAME_DEFAULT="cloudkitty" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" + +# Define the Global Overrides directory used in the original script GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE @@ -30,20 +33,55 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -58,8 +96,9 @@ else fi # Include all YAML files from the GLOBAL configuration directory +# NOTE: Files here override base settings and are applied before service-specific ones. if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then - echo "Including overrides from global config directory:" + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -67,10 +106,11 @@ if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES_DIR" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -85,10 +125,6 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely set_args=( --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" @@ -103,7 +139,7 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -114,7 +150,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -124,4 +160,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-envoy-gateway.sh b/bin/install-envoy-gateway.sh index b6a66a5d..0dbb204f 100755 --- a/bin/install-envoy-gateway.sh +++ b/bin/install-envoy-gateway.sh @@ -1,26 +1,26 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="envoyproxy-gateway" +SERVICE_NAME_DEFAULT="envoyproxy-gateway" SERVICE_NAMESPACE="envoyproxy-gateway-system" # Helm # NOTE: Using OCI registry format for the chart location. -HELM_REPO_NAME="oci://docker.io/envoyproxy" -HELM_REPO_URL="gateway-helm" +HELM_REPO_NAME_DEFAULT="gateway-helm" +HELM_REPO_URL_DEFAULT="oci://docker.io/envoyproxy" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" @@ -30,15 +30,48 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then echo "Error: Could not extract version for 'envoy' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() @@ -74,15 +107,14 @@ fi echo -# --- Helm Repository and Execution --- # Collect all --set arguments, executing commands and quoting safely set_args=() helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$HELM_REPO_URL" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" - --namespace="$SERVICE_NAMESPACE" + --namespace "${SERVICE_NAMESPACE}" --timeout 120m --create-namespace @@ -91,7 +123,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) diff --git a/bin/install-fluentbit.sh b/bin/install-fluentbit.sh index 84e0bfb6..02ed0017 100755 --- a/bin/install-fluentbit.sh +++ b/bin/install-fluentbit.sh @@ -1,28 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="fluentbit" +SERVICE_NAME_DEFAULT="fluentbit" SERVICE_NAMESPACE="fluentbit" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${SERVICE_BASE_OVERRIDES:-$GENESTACK_BASE_DIR/base-helm-configs/$SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${SERVICE_CUSTOM_OVERRIDES:-$GENESTACK_OVERRIDES_DIR/helm-configs/$SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" -# Define the Global Overrides directory -GLOBAL_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" +# Define the Global Overrides directory used in the original script +GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" @@ -32,20 +32,55 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() -# Include all YAML files from the BASE configuration directory +# Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -59,9 +94,24 @@ else echo "Warning: Base override directory not found: $SERVICE_BASE_OVERRIDES" fi +# Include all YAML files from the GLOBAL configuration directory +# NOTE: Files here override base settings and are applied before service-specific ones. +if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" + for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do + if [[ -e "$file" ]]; then + echo " - $file" + overrides_args+=("-f" "$file") + fi + done +else + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" +fi + # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then - echo "Including overrides from config directory:" + echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -69,25 +119,29 @@ if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then fi done else - echo "Warning: Config directory not found: $SERVICE_CUSTOM_OVERRIDES" + echo "Warning: Service config directory not found: $SERVICE_CUSTOM_OVERRIDES" fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update +# Collect all --set arguments, executing commands and quoting safely +set_args=() + helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME"/"$SERVICE_NAME" - --create-namespace --namespace="$SERVICE_NAMESPACE" --timeout 10m + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" + --namespace="$SERVICE_NAMESPACE" + --timeout 120m + --create-namespace "${overrides_args[@]}" + "${set_args[@]}" # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" + "$@" ) @@ -96,4 +150,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-freezer.sh b/bin/install-freezer.sh index a3dc0b29..599b9631 100755 --- a/bin/install-freezer.sh +++ b/bin/install-freezer.sh @@ -1,25 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="freezer" +# The service name is used for both the release name and the chart name. +SERVICE_NAME_DEFAULT="freezer" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" + +# Define the Global Overrides directory used in the original script GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE @@ -30,20 +33,55 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -58,8 +96,9 @@ else fi # Include all YAML files from the GLOBAL configuration directory +# NOTE: Files here override base settings and are applied before service-specific ones. if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then - echo "Including overrides from global config directory:" + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -67,10 +106,11 @@ if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES_DIR" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -85,10 +125,6 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely set_args=( --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" @@ -103,7 +139,7 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -114,7 +150,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -124,4 +160,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-glance.sh b/bin/install-glance.sh index f956c3fe..2f5bb270 100755 --- a/bin/install-glance.sh +++ b/bin/install-glance.sh @@ -1,25 +1,27 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="glance" +SERVICE_NAME_DEFAULT="glance" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" + +# Define the Global Overrides directory used in the original script GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE @@ -30,20 +32,54 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -58,8 +94,9 @@ else fi # Include all YAML files from the GLOBAL configuration directory +# NOTE: Files here override base settings and are applied before service-specific ones. if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then - echo "Including overrides from global config directory:" + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -67,10 +104,11 @@ if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES_DIR" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -85,11 +123,9 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely +# NOTE: This array contains OpenStack-specific secret retrievals and MUST be updated +# with the necessary --set arguments for your target SERVICE_NAME_DEFAULT. set_args=( --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" --set "endpoints.identity.auth.glance.password=$(kubectl --namespace openstack get secret glance-admin -o jsonpath='{.data.password}' | base64 -d)" @@ -103,7 +139,7 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -114,7 +150,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -124,4 +160,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-gnocchi.sh b/bin/install-gnocchi.sh index cfa2accc..58c24194 100755 --- a/bin/install-gnocchi.sh +++ b/bin/install-gnocchi.sh @@ -1,25 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="gnocchi" +# The service name is used for both the release name and the chart name. +SERVICE_NAME_DEFAULT="gnocchi" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" + +# Define the Global Overrides directory used in the original script GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE @@ -30,20 +33,55 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -58,8 +96,9 @@ else fi # Include all YAML files from the GLOBAL configuration directory +# NOTE: Files here override base settings and are applied before service-specific ones. if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then - echo "Including overrides from global config directory:" + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -67,10 +106,11 @@ if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES_DIR" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -85,10 +125,6 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely set_args=( --set "conf.ceph.admin_keyring=$(kubectl get secret --namespace rook-ceph rook-ceph-admin-keyring -o jsonpath='{.data.keyring}' | base64 -d)" @@ -104,10 +140,10 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" - --timeout 120m # Set to standard 120m + --timeout 120m --create-namespace "${overrides_args[@]}" @@ -115,7 +151,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -125,4 +161,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-grafana.sh b/bin/install-grafana.sh index a09e910e..3803876f 100755 --- a/bin/install-grafana.sh +++ b/bin/install-grafana.sh @@ -1,26 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="grafana" +SERVICE_NAME_DEFAULT="grafana" SERVICE_NAMESPACE="grafana" # Helm -HELM_REPO_NAME="grafana" -HELM_REPO_URL="https://grafana.github.io/helm-charts" +HELM_REPO_NAME_DEFAULT="grafana" +HELM_REPO_URL_DEFAULT="https://grafana.github.io/helm-charts" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" -GLOBAL_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" + +# Define the Global Overrides directory used in the original script +GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" @@ -30,20 +32,55 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -58,20 +95,21 @@ else fi # Include all YAML files from the GLOBAL configuration directory -# UPDATED: Using GLOBAL_OVERRIDES variable -if [[ -d "$GLOBAL_OVERRIDES" ]]; then - echo "Including overrides from global config directory:" - for file in "$GLOBAL_OVERRIDES"/*.yaml; do +# NOTE: Files here override base settings and are applied before service-specific ones. +if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" + for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" overrides_args+=("-f" "$file") fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -86,16 +124,12 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments (empty for Grafana in the original script) set_args=() helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -106,7 +140,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -116,4 +150,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-heat.sh b/bin/install-heat.sh index d44e2df8..eabb49bc 100755 --- a/bin/install-heat.sh +++ b/bin/install-heat.sh @@ -1,28 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="heat" +SERVICE_NAME_DEFAULT="heat" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Define the Global Overrides directory used in the original script -GLOBAL_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" +GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" @@ -32,20 +32,54 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -60,19 +94,21 @@ else fi # Include all YAML files from the GLOBAL configuration directory -if [[ -d "$GLOBAL_OVERRIDES" ]]; then - echo "Including overrides from global config directory:" - for file in "$GLOBAL_OVERRIDES"/*.yaml; do +# NOTE: Files here override base settings and are applied before service-specific ones. +if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" + for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" overrides_args+=("-f" "$file") fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -87,11 +123,9 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely +# NOTE: This array contains OpenStack-specific secret retrievals and MUST be updated +# with the necessary --set arguments for your target SERVICE_NAME_DEFAULT. set_args=( --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" --set "endpoints.identity.auth.heat.password=$(kubectl --namespace openstack get secret heat-admin -o jsonpath='{.data.password}' | base64 -d)" @@ -107,7 +141,7 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -118,7 +152,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -128,4 +162,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-horizon.sh b/bin/install-horizon.sh index d383edfa..78209353 100755 --- a/bin/install-horizon.sh +++ b/bin/install-horizon.sh @@ -1,28 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="horizon" +SERVICE_NAME_DEFAULT="horizon" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Define the Global Overrides directory used in the original script -GLOBAL_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" +GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" @@ -32,20 +32,55 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -60,19 +95,21 @@ else fi # Include all YAML files from the GLOBAL configuration directory -if [[ -d "$GLOBAL_OVERRIDES" ]]; then - echo "Including overrides from global config directory:" - for file in "$GLOBAL_OVERRIDES"/*.yaml; do +# NOTE: Files here override base settings and are applied before service-specific ones. +if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" + for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" overrides_args+=("-f" "$file") fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -87,10 +124,6 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely set_args=( --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" @@ -102,7 +135,7 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -113,7 +146,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -123,4 +156,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-ironic.sh b/bin/install-ironic.sh index 61a13fbc..69f30ac9 100755 --- a/bin/install-ironic.sh +++ b/bin/install-ironic.sh @@ -1,28 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="ironic" +SERVICE_NAME_DEFAULT="ironic" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Define the Global Overrides directory used in the original script -GLOBAL_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" +GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" @@ -32,20 +32,54 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -60,19 +94,21 @@ else fi # Include all YAML files from the GLOBAL configuration directory -if [[ -d "$GLOBAL_OVERRIDES" ]]; then - echo "Including overrides from global config directory:" - for file in "$GLOBAL_OVERRIDES"/*.yaml; do +# NOTE: Files here override base settings and are applied before service-specific ones. +if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" + for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" overrides_args+=("-f" "$file") fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -87,11 +123,9 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely +# NOTE: This array contains OpenStack-specific secret retrievals and MUST be updated +# with the necessary --set arguments for your target SERVICE_NAME_DEFAULT. set_args=( --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" --set "endpoints.identity.auth.ironic.password=$(kubectl --namespace openstack get secret ironic-admin -o jsonpath='{.data.password}' | base64 -d)" @@ -100,13 +134,14 @@ set_args=( --set "endpoints.oslo_db.auth.ironic.password=$(kubectl --namespace openstack get secret ironic-db-password -o jsonpath='{.data.password}' | base64 -d)" --set "endpoints.oslo_cache.auth.memcache_secret_key=$(kubectl --namespace openstack get secret os-memcached -o jsonpath='{.data.memcache_secret_key}' | base64 -d)" --set "conf.ironic.keystone_authtoken.memcache_secret_key=$(kubectl --namespace openstack get secret os-memcached -o jsonpath='{.data.memcache_secret_key}' | base64 -d)" + --set "conf.ironic.database.slave_connection=mysql+pymysql://ironic:$(kubectl --namespace openstack get secret ironic-db-password -o jsonpath='{.data.password}' | base64 -d)@mariadb-cluster-secondary.openstack.svc.cluster.local:3306/ironic" --set "endpoints.oslo_messaging.auth.admin.password=$(kubectl --namespace openstack get secret rabbitmq-default-user -o jsonpath='{.data.password}' | base64 -d)" --set "endpoints.oslo_messaging.auth.ironic.password=$(kubectl --namespace openstack get secret ironic-rabbitmq-password -o jsonpath='{.data.password}' | base64 -d)" ) helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -117,7 +152,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -127,4 +162,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-keystone.sh b/bin/install-keystone.sh index 68e7e4af..2cb6ae40 100755 --- a/bin/install-keystone.sh +++ b/bin/install-keystone.sh @@ -1,28 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="keystone" +SERVICE_NAME_DEFAULT="keystone" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Define the Global Overrides directory used in the original script -GLOBAL_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" +GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" @@ -32,20 +32,54 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -60,19 +94,21 @@ else fi # Include all YAML files from the GLOBAL configuration directory -if [[ -d "$GLOBAL_OVERRIDES" ]]; then - echo "Including overrides from global config directory:" - for file in "$GLOBAL_OVERRIDES"/*.yaml; do +# NOTE: Files here override base settings and are applied before service-specific ones. +if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" + for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" overrides_args+=("-f" "$file") fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -87,11 +123,9 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely +# NOTE: This array contains OpenStack-specific secret retrievals and MUST be updated +# with the necessary --set arguments for your target SERVICE_NAME_DEFAULT. set_args=( --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" --set "endpoints.oslo_db.auth.admin.password=$(kubectl --namespace openstack get secret mariadb -o jsonpath='{.data.root-password}' | base64 -d)" @@ -103,7 +137,7 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -114,7 +148,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -124,4 +158,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-kube-ovn.sh b/bin/install-kube-ovn.sh index 005a4644..c46ba90d 100755 --- a/bin/install-kube-ovn.sh +++ b/bin/install-kube-ovn.sh @@ -1,28 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="kube-ovn" +SERVICE_NAME_DEFAULT="kube-ovn" SERVICE_NAMESPACE="kube-system" # Note: kube-ovn uses the kube-system namespace # Helm -HELM_REPO_NAME="kubeovn" -HELM_REPO_URL="https://kubeovn.github.io/kube-ovn" +HELM_REPO_NAME_DEFAULT="kubeovn" +HELM_REPO_URL_DEFAULT="https://kubeovn.github.io/kube-ovn" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Define the Global Overrides directory used in the original script -GLOBAL_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" +GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" @@ -32,15 +32,15 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" # --- Kube-OVN specific logic to determine masters and replica count --- MASTER_NODES=$(kubectl get nodes -l kube-ovn/role=master -o json | jq -r '[.items[].status.addresses[] | select(.type == "InternalIP") | .address] | join(",")' | sed 's/,/\\,/g') @@ -54,10 +54,44 @@ fi echo "Found $MASTER_NODE_COUNT master node(s) with IPs: ${MASTER_NODES//\\,/ }." # -------------------------------------------------------------------- +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" + # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -72,19 +106,21 @@ else fi # Include all YAML files from the GLOBAL configuration directory -if [[ -d "$GLOBAL_OVERRIDES" ]]; then - echo "Including overrides from global config directory:" - for file in "$GLOBAL_OVERRIDES"/*.yaml; do +# NOTE: Files here override base settings and are applied before service-specific ones. +if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" + for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" overrides_args+=("-f" "$file") fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -99,10 +135,6 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely set_args=( --set "MASTER_NODES=${MASTER_NODES}" @@ -111,7 +143,7 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -122,7 +154,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) diff --git a/bin/install-kube-prometheus-stack.sh b/bin/install-kube-prometheus-stack.sh index c27f77ef..4739ab18 100755 --- a/bin/install-kube-prometheus-stack.sh +++ b/bin/install-kube-prometheus-stack.sh @@ -1,25 +1,25 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="kube-prometheus-stack" +SERVICE_NAME_DEFAULT="kube-prometheus-stack" SERVICE_NAMESPACE="prometheus" # Helm -HELM_REPO_NAME="prometheus-community" -HELM_REPO_URL="https://prometheus-community.github.io/helm-charts" +HELM_REPO_NAME_DEFAULT="prometheus-community" +HELM_REPO_URL_DEFAULT="https://prometheus-community.github.io/helm-charts" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Prometheus Rules directory (specific to this service's needs) GENESTACK_PROMETHEUS_RULES_DIR="${SERVICE_BASE_OVERRIDES}/rules" @@ -32,24 +32,56 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() -# Include all YAML files from the BASE configuration directory and the rules subdirectory +# Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" - - # Include YAML files directly in the base directory (e.g., specific overrides) for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do # Check that there is at least one match if [[ -e "$file" ]]; then @@ -75,6 +107,7 @@ else fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -89,16 +122,12 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - -# Collect all --set arguments (none in the original script) +# Collect all --set arguments, executing commands and quoting safely set_args=() helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -109,7 +138,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) diff --git a/bin/install-kubernetes-event-exporter.sh b/bin/install-kubernetes-event-exporter.sh index b0bf2f83..b99108ee 100755 --- a/bin/install-kubernetes-event-exporter.sh +++ b/bin/install-kubernetes-event-exporter.sh @@ -1,25 +1,25 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="kubernetes-event-exporter" +SERVICE_NAME_DEFAULT="kubernetes-event-exporter" SERVICE_NAMESPACE="monitoring" # Helm -HELM_REPO_NAME="bitnami" -HELM_REPO_URL="https://charts.bitnami.com/bitnami" +HELM_REPO_NAME_DEFAULT="bitnami" +HELM_REPO_URL_DEFAULT="https://charts.bitnami.com/bitnami" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" @@ -29,26 +29,61 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically. Note: the service name in the YAML is 'kubernetes-event-exporter'. -SERVICE_VERSION=$(grep "kubernetes-event-exporter:" "$VERSION_FILE" | sed 's/.*kubernetes-event-exporter: *//') +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for 'kubernetes-event-exporter' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() -# Base Override Files: Check the standard base directory. +# Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" + # Include YAML files directly in the base directory (e.g., specific overrides) for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do # Check that there is at least one match if [[ -e "$file" ]]; then - echo " - $file" + echo " - $file (Base Config)" overrides_args+=("-f" "$file") fi done @@ -57,8 +92,9 @@ else fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then - echo "Including overrides from config directory:" + echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -66,25 +102,29 @@ if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then fi done else - echo "Warning: Config directory not found: $SERVICE_CUSTOM_OVERRIDES" + echo "Warning: Service config directory not found: $SERVICE_CUSTOM_OVERRIDES" fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update +# Collect all --set arguments (none in the original script) +set_args=() + helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME"/"$SERVICE_NAME" - --create-namespace --namespace="$SERVICE_NAMESPACE" --timeout 120m + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" + --namespace="$SERVICE_NAMESPACE" + --timeout 120m + --create-namespace "${overrides_args[@]}" + "${set_args[@]}" # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" + "$@" ) @@ -93,4 +133,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-libvirt.sh b/bin/install-libvirt.sh index 4fd5cbcb..d48388a4 100755 --- a/bin/install-libvirt.sh +++ b/bin/install-libvirt.sh @@ -1,28 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="libvirt" +SERVICE_NAME_DEFAULT="libvirt" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Define the Global Overrides directory used in the original script -GLOBAL_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" +GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" @@ -32,20 +32,54 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -60,19 +94,21 @@ else fi # Include all YAML files from the GLOBAL configuration directory -if [[ -d "$GLOBAL_OVERRIDES" ]]; then - echo "Including overrides from global config directory:" - for file in "$GLOBAL_OVERRIDES"/*.yaml; do +# NOTE: Files here override base settings and are applied before service-specific ones. +if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" + for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" overrides_args+=("-f" "$file") fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -87,16 +123,12 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments (none in the original script) set_args=() helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -107,7 +139,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -117,4 +149,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-longhorn.sh b/bin/install-longhorn.sh index 9a2cbd0a..42e59263 100755 --- a/bin/install-longhorn.sh +++ b/bin/install-longhorn.sh @@ -1,28 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="longhorn" +SERVICE_NAME_DEFAULT="longhorn" SERVICE_NAMESPACE="longhorn-system" # Helm -HELM_REPO_NAME="longhorn" -HELM_REPO_URL="https://charts.longhorn.io" +HELM_REPO_NAME_DEFAULT="longhorn" +HELM_REPO_URL_DEFAULT="https://charts.longhorn.io" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Define the Global Overrides directory used in the original script -GLOBAL_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" +GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" @@ -32,20 +32,54 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -60,19 +94,21 @@ else fi # Include all YAML files from the GLOBAL configuration directory -if [[ -d "$GLOBAL_OVERRIDES" ]]; then - echo "Including overrides from global config directory:" - for file in "$GLOBAL_OVERRIDES"/*.yaml; do +# NOTE: Files here override base settings and are applied before service-specific ones. +if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" + for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" overrides_args+=("-f" "$file") fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -87,10 +123,6 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely set_args=( --set "persistence.defaultClass=false" @@ -98,7 +130,7 @@ set_args=( ) helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -109,7 +141,7 @@ helm_command=( # Post-renderer configuration (Longhorn generally doesn't use this, but keeping for template adherence) --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -119,4 +151,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-magnum.sh b/bin/install-magnum.sh index 1ad38d3f..8b19b1f7 100755 --- a/bin/install-magnum.sh +++ b/bin/install-magnum.sh @@ -1,28 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="magnum" +SERVICE_NAME_DEFAULT="magnum" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Define the Global Overrides directory used in the original script -GLOBAL_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" +GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" @@ -32,20 +32,54 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -60,19 +94,21 @@ else fi # Include all YAML files from the GLOBAL configuration directory -if [[ -d "$GLOBAL_OVERRIDES" ]]; then - echo "Including overrides from global config directory:" - for file in "$GLOBAL_OVERRIDES"/*.yaml; do +# NOTE: Files here override base settings and are applied before service-specific ones. +if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" + for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" overrides_args+=("-f" "$file") fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -87,10 +123,6 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely set_args=( --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" @@ -103,9 +135,8 @@ set_args=( --set "conf.magnum.keystone_authtoken.memcache_secret_key=$(kubectl --namespace openstack get secret os-memcached -o jsonpath='{.data.memcache_secret_key}' | base64 -d)" ) - helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -116,7 +147,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -126,4 +157,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-manila.sh b/bin/install-manila.sh index bac719bc..efc9a36d 100755 --- a/bin/install-manila.sh +++ b/bin/install-manila.sh @@ -1,26 +1,27 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="manila" +SERVICE_NAME_DEFAULT="manila" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment -# Using provided defaults if not set in environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" + +# Define the Global Overrides directory used in the original script GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE @@ -31,20 +32,54 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" -# Prepare an array to collect --values arguments + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" + +# Prepare an array to collect -f arguments overrides_args=() -# --- Include all YAML files from the BASE configuration directory --- +# Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" # NOTE: The original manila script explicitly used manila-helm-overrides.yaml. @@ -52,33 +87,35 @@ if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do # Check that there is at least one match if [[ -e "$file" ]]; then - echo " -f $file" - overrides_args+=("--values" "$file") + echo " - $file" + overrides_args+=("-f" "$file") fi done else echo "Warning: Base override directory not found: $SERVICE_BASE_OVERRIDES" fi -# --- Include all YAML files from the GLOBAL configuration directory --- +# Include all YAML files from the GLOBAL configuration directory +# NOTE: Files here override base settings and are applied before service-specific ones. if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then - echo "Including overrides from global config directory:" + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then - echo " -f $file" - overrides_args+=("--values" "$file") + echo " - $file" + overrides_args+=("-f" "$file") fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES_DIR" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi -# --- Include all YAML files from the custom SERVICE configuration directory --- +# Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do if [[ -e "$file" ]]; then - echo " -f $file" + echo " - $file" overrides_args+=("-f" "$file") fi done @@ -88,10 +125,6 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely set_args=( --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" @@ -108,7 +141,7 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -119,7 +152,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -129,4 +162,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-mariadb-operator.sh b/bin/install-mariadb-operator.sh index 692d24ee..e4b643ea 100755 --- a/bin/install-mariadb-operator.sh +++ b/bin/install-mariadb-operator.sh @@ -1,75 +1,166 @@ #!/bin/bash +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified +# YAML file and executes a helm upgrade/install command with dynamic values files. + +# Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 +# Service +SERVICE_NAME_DEFAULT="mariadb-operator" +CRDS_NAME_DEFAULT="mariadb-operator-crds" +SERVICE_NAMESPACE="mariadb-system" + +# Helm +HELM_REPO_NAME_DEFAULT="mariadb-operator" +HELM_REPO_URL_DEFAULT="https://helm.mariadb.com/mariadb-operator" + # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" -# Read mariadb-operator version from helm-chart-versions.yaml +# Define service-specific override directories based on the framework +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" + +# Define the Global Overrides directory used in the original script +GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" + +# Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" + if [ ! -f "$VERSION_FILE" ]; then - echo "Error: helm-chart-versions.yaml not found at $VERSION_FILE" + echo "Error: helm-chart-versions.yaml not found at $VERSION_FILE" >&2 exit 1 fi -# Extract mariadb-operator version using grep and sed -MARIADB_OPERATOR_VERSION=$(grep 'mariadb-operator:' "$VERSION_FILE" | sed 's/.*mariadb-operator: *//') +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") -if [ -z "$MARIADB_OPERATOR_VERSION" ]; then - echo "Error: Could not extract mariadb-operator version from $VERSION_FILE" +if [ -z "$SERVICE_VERSION" ]; then + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + # Default parameter value export CLUSTER_NAME=${CLUSTER_NAME:-cluster.local} -# Directory to check for YAML files -CONFIG_DIR="/etc/genestack/helm-configs/mariadb-operator" # 'cluster.local' is the default value in base helm values file if [ "${CLUSTER_NAME}" != "cluster.local" ]; then - CONFIG_FILE="$CONFIG_DIR/mariadb-operator-helm-overrides.yaml" - mkdir -p $CONFIG_DIR - touch "$CONFIG_FILE" + SERVICE_CONFIG_FILE="$SERVICE_CUSTOM_OVERRIDES/mariadb-operator-helm-overrides.yaml" + touch "$SERVICE_CONFIG_FILE" # Check if the file is empty and add/modify content accordingly - if [ ! -s "$CONFIG_FILE" ]; then - echo "clusterName: $CLUSTER_NAME" > "$CONFIG_FILE" + if [ ! -s "$SERVICE_CONFIG_FILE" ]; then + echo "clusterName: $CLUSTER_NAME" > "$SERVICE_CONFIG_FILE" else # If the clusterName line exists, modify it, otherwise add it at the end - if grep -q "^clusterName:" "$CONFIG_FILE"; then - sed -i -e "s/^clusterName: .*/clusterName: ${CLUSTER_NAME}/" "$CONFIG_FILE" + if grep -q "^clusterName:" "$SERVICE_CONFIG_FILE"; then + sed -i -e "s/^clusterName: .*/clusterName: ${CLUSTER_NAME}/" "$SERVICE_CONFIG_FILE" else - echo "clusterName: $CLUSTER_NAME" >> "$CONFIG_FILE" + echo "clusterName: $CLUSTER_NAME" >> "$SERVICE_CONFIG_FILE" fi fi fi -# Add the mariadb-operator helm repository -helm repo add mariadb-operator https://helm.mariadb.com/mariadb-operator -helm repo update +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + CRDS_NAME=$(yq eval '.chart.service_crds // ""' "$yaml_file") + break # use the first match and stop + fi +done -# Install the CRDs that match the version defined -helm upgrade --install --namespace=mariadb-system --create-namespace mariadb-operator-crds mariadb-operator/mariadb-operator-crds --version "${MARIADB_OPERATOR_VERSION}" - -# Helm command setup -HELM_CMD="helm upgrade --install mariadb-operator mariadb-operator/mariadb-operator \ - --namespace=mariadb-system \ - --timeout 120m \ - --version ${MARIADB_OPERATOR_VERSION} \ - --post-renderer /etc/genestack/kustomize/kustomize.sh \ - --post-renderer-args mariadb-operator/overlay \ - -f /opt/genestack/base-helm-configs/mariadb-operator/mariadb-operator-helm-overrides.yaml" - -# Check if YAML files exist in the specified directory -if compgen -G "${CONFIG_DIR}/*.yaml" > /dev/null; then - # Add all YAML files from the directory to the helm command - for yaml_file in "${CONFIG_DIR}"/*.yaml; do - HELM_CMD+=" -f ${yaml_file}" +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" +: "${CRDS_NAME:=$CRDS_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + CRDS_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$CRDS_NAME" + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + CRDS_CHART_PATH="$HELM_REPO_NAME/$CRDS_NAME" + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] CRDS_NAME=$CRDS_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" +echo "[DEBUG] CRDS_CHART_PATH=$CRDS_CHART_PATH" + +# Prepare an array to collect -f arguments +overrides_args=() + +# Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. +if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then + echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" + for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do + # Check that there is at least one match + if [[ -e "$file" ]]; then + echo " - $file" + overrides_args+=("-f" "$file") + fi done +else + echo "Warning: Base override directory not found: $SERVICE_BASE_OVERRIDES" fi -HELM_CMD+=" $@" +# Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. +if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then + echo "Including overrides from service config directory: $SERVICE_CUSTOM_OVERRIDES" + for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do + if [[ -e "$file" ]]; then + echo " - $file" + overrides_args+=("-f" "$file") + fi + done +else + echo "Warning: Service overrides directory not found: $SERVICE_CUSTOM_OVERRIDES" +fi + +echo + +# Collect all --set arguments, executing commands and quoting safely +set_args=() + +# Install the CRDs that match the version defined +helm upgrade --install --namespace="$SERVICE_NAMESPACE" --create-namespace "$CRDS_NAME_DEFAULT" "$CRDS_CHART_PATH" --version "${SERVICE_VERSION}" + +helm_command=( + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" + --version "${SERVICE_VERSION}" + --namespace="$SERVICE_NAMESPACE" + --timeout 120m + + "${overrides_args[@]}" + "${set_args[@]}" + + # Post-renderer configuration + --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" + + "$@" +) + +echo "Executing Helm command (arguments are quoted safely):" +printf '%q ' "${helm_command[@]}" +echo -# Run the helm command -echo "Executing Helm command:" -echo "${HELM_CMD}" -eval "${HELM_CMD}" +# Execute the command directly from the array +"${helm_command[@]}" diff --git a/bin/install-masakari.sh b/bin/install-masakari.sh index 8c2aa99c..6ceac6b4 100755 --- a/bin/install-masakari.sh +++ b/bin/install-masakari.sh @@ -1,28 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="masakari" +SERVICE_NAME_DEFAULT="masakari" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Define the Global Overrides directory used in the original script -GLOBAL_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" +GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" @@ -32,20 +32,54 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -60,19 +94,21 @@ else fi # Include all YAML files from the GLOBAL configuration directory -if [[ -d "$GLOBAL_OVERRIDES" ]]; then - echo "Including overrides from global config directory:" - for file in "$GLOBAL_OVERRIDES"/*.yaml; do +# NOTE: Files here override base settings and are applied before service-specific ones. +if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" + for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" overrides_args+=("-f" "$file") fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -87,10 +123,6 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely set_args=( --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" @@ -105,7 +137,7 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -116,7 +148,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -126,4 +158,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-memcached.sh b/bin/install-memcached.sh index 375c57d0..2ee518dd 100755 --- a/bin/install-memcached.sh +++ b/bin/install-memcached.sh @@ -1,53 +1,140 @@ #!/bin/bash +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified +# YAML file and executes a helm upgrade/install command with dynamic values files. + +# Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 + +# Service +SERVICE_NAME_DEFAULT="memcached" +SERVICE_NAMESPACE="openstack" + +# Helm +HELM_REPO_NAME_DEFAULT="bitnami" +HELM_REPO_URL_DEFAULT="https://charts.bitnami.com/bitnami" + # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" -GLOBAL_OVERRIDES_DIR="/etc/genestack/helm-configs/global_overrides" -SERVICE_CONFIG_DIR="/etc/genestack/helm-configs/memcached" -BASE_OVERRIDES="/opt/genestack/base-helm-configs/memcached/memcached-helm-overrides.yaml" +# Define service-specific override directories based on the framework +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" + +# Define the Global Overrides directory used in the original script +GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" -# Read memcached version from helm-chart-versions.yaml +# Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" + if [ ! -f "$VERSION_FILE" ]; then - echo "Error: helm-chart-versions.yaml not found at $VERSION_FILE" + echo "Error: helm-chart-versions.yaml not found at $VERSION_FILE" >&2 exit 1 fi -# Extract memcached version using grep and sed -MEMCACHED_VERSION=$(grep 'memcached:' "$VERSION_FILE" | sed 's/.*memcached: *//') +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") -if [ -z "$MEMCACHED_VERSION" ]; then - echo "Error: Could not extract memcached version from $VERSION_FILE" +if [ -z "$SERVICE_VERSION" ]; then + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -HELM_CMD="helm upgrade --install memcached bitnami/memcached \ - --version ${MEMCACHED_VERSION} \ - --namespace=openstack \ - --timeout 120m \ - --post-renderer /etc/genestack/kustomize/kustomize.sh \ - --post-renderer-args memcached/overlay" - -HELM_CMD+=" -f ${BASE_OVERRIDES}" - -for dir in "$GLOBAL_OVERRIDES_DIR" "$SERVICE_CONFIG_DIR"; do - if compgen -G "${dir}/*.yaml" > /dev/null; then - for yaml_file in "${dir}"/*.yaml; do - # Avoid re-adding the base override file if present in the service directory - if [ "${yaml_file}" != "${BASE_OVERRIDES}" ]; then - HELM_CMD+=" -f ${yaml_file}" - fi - done +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop fi done -HELM_CMD+=" $@" +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" + +# Prepare an array to collect -f arguments +overrides_args=() + +# Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. +if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then + echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" + for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do + # Check that there is at least one match + if [[ -e "$file" ]]; then + echo " - $file" + overrides_args+=("-f" "$file") + fi + done +else + echo "Warning: Base override directory not found: $SERVICE_BASE_OVERRIDES" +fi + +# Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. +if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then + echo "Including overrides from service config directory: $SERVICE_CUSTOM_OVERRIDES" + for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do + if [[ -e "$file" ]]; then + echo " - $file" + overrides_args+=("-f" "$file") + fi + done +else + echo "Warning: Service overrides directory not found: $SERVICE_CUSTOM_OVERRIDES" +fi + +echo + +# Collect all --set arguments, executing commands and quoting safely +set_args=() + + +helm_command=( + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" + --version "${SERVICE_VERSION}" + --namespace="$SERVICE_NAMESPACE" + --timeout 120m + --create-namespace + + "${overrides_args[@]}" + "${set_args[@]}" + + # Post-renderer configuration + # NOTE: Metallb doesn't typically require a post-renderer, but we keep it + # for template compliance. + --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" + + "$@" +) -helm repo add bitnami https://charts.bitnami.com/bitnami -helm repo update +echo "Executing Helm command (arguments are quoted safely):" +printf '%q ' "${helm_command[@]}" +echo -echo "Executing Helm command:" -echo "${HELM_CMD}" -eval "${HELM_CMD}" +# Execute the command directly from the array +"${helm_command[@]}" diff --git a/bin/install-metallb.sh b/bin/install-metallb.sh index 3553a20d..0492d70e 100755 --- a/bin/install-metallb.sh +++ b/bin/install-metallb.sh @@ -1,25 +1,27 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="metallb" +SERVICE_NAME_DEFAULT="metallb" SERVICE_NAMESPACE="metallb-system" # Helm -HELM_REPO_NAME="metallb" -HELM_REPO_URL="https://metallb.github.io/metallb" +HELM_REPO_NAME_DEFAULT="metallb" +HELM_REPO_URL_DEFAULT="https://metallb.github.io/metallb" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" + +# Define the Global Overrides directory used in the original script GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE @@ -30,20 +32,54 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -58,8 +94,9 @@ else fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then - echo "Including overrides from service config directory:" + echo "Including overrides from service config directory: $SERVICE_CUSTOM_OVERRIDES" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -67,21 +104,17 @@ if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then fi done else - echo "Warning: Service config directory not found: $SERVICE_CUSTOM_OVERRIDES" + echo "Warning: Service overrides directory not found: $SERVICE_CUSTOM_OVERRIDES" fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely set_args=() helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -94,7 +127,7 @@ helm_command=( # NOTE: Metallb doesn't typically require a post-renderer, but we keep it # for template compliance. --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -104,4 +137,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-neutron.sh b/bin/install-neutron.sh index 1a41c34d..3595bc3d 100755 --- a/bin/install-neutron.sh +++ b/bin/install-neutron.sh @@ -1,28 +1,31 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="neutron" +SERVICE_NAME_DEFAULT="neutron" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" + +# Define the Global Overrides directory used in the original script GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE +# NOTE: Ensure this file exists and contains an entry for SERVICE_NAME_DEFAULT. VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" if [ ! -f "$VERSION_FILE" ]; then @@ -30,15 +33,48 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() @@ -61,7 +97,7 @@ fi # Include all YAML files from the GLOBAL configuration directory # NOTE: Files here override base settings and are applied before service-specific ones. if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then - echo "Including overrides from global config directory:" + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -69,7 +105,7 @@ if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES_DIR" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory @@ -88,13 +124,9 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely # NOTE: This array contains OpenStack-specific secret retrievals and MUST be updated -# with the necessary --set arguments for your target SERVICE_NAME. +# with the necessary --set arguments for your target SERVICE_NAME_DEFAULT. set_args=( # Metadata proxy secret --set "conf.metadata_agent.DEFAULT.metadata_proxy_shared_secret=$(kubectl --namespace openstack get secret metadata-shared-secret -o jsonpath='{.data.password}' | base64 -d)" @@ -119,7 +151,7 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -130,7 +162,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -140,4 +172,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-nova.sh b/bin/install-nova.sh index 065d564d..2da5f39a 100755 --- a/bin/install-nova.sh +++ b/bin/install-nova.sh @@ -1,25 +1,27 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="nova" +SERVICE_NAME_DEFAULT="nova" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" + +# Define the Global Overrides directory used in the original script GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE @@ -30,20 +32,54 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -58,8 +94,9 @@ else fi # Include all YAML files from the GLOBAL configuration directory +# NOTE: Files here override base settings and are applied before service-specific ones. if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then - echo "Including overrides from global config directory:" + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -67,10 +104,11 @@ if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES_DIR" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -85,11 +123,9 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely +# NOTE: This array contains OpenStack-specific secret retrievals and MUST be updated +# with the necessary --set arguments for your target SERVICE_NAME_DEFAULT. set_args=( --set "conf.nova.neutron.metadata_proxy_shared_secret=$(kubectl --namespace openstack get secret metadata-shared-secret -o jsonpath='{.data.password}' | base64 -d)" --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" @@ -114,7 +150,7 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -125,7 +161,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -135,4 +171,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-octavia.sh b/bin/install-octavia.sh index eab752b0..bb08298e 100755 --- a/bin/install-octavia.sh +++ b/bin/install-octavia.sh @@ -1,30 +1,30 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="octavia" +SERVICE_NAME_DEFAULT="octavia" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment -# NOTE: These are framework-specific defaults; adjust if your environment uses different paths. GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" + +# Define the Global Overrides directory used in the original script GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE -# NOTE: Ensure this file exists and contains an entry for SERVICE_NAME. VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" if [ ! -f "$VERSION_FILE" ]; then @@ -32,15 +32,48 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() @@ -63,7 +96,7 @@ fi # Include all YAML files from the GLOBAL configuration directory # NOTE: Files here override base settings and are applied before service-specific ones. if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then - echo "Including overrides from global config directory:" + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -71,7 +104,7 @@ if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES_DIR" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory @@ -90,13 +123,9 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely # NOTE: This array contains OpenStack-specific secret retrievals and MUST be updated -# with the necessary --set arguments for your target SERVICE_NAME. +# with the necessary --set arguments for your target SERVICE_NAME_DEFAULT. set_args=( # Keystone endpoint passwords --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" @@ -125,7 +154,7 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -135,9 +164,8 @@ helm_command=( "${set_args[@]}" # Post-renderer configuration - # NOTE: Update the path and args if your service uses a different kustomization overlay. --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -147,4 +175,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-placement.sh b/bin/install-placement.sh index b9cadd60..08a88a3f 100755 --- a/bin/install-placement.sh +++ b/bin/install-placement.sh @@ -1,17 +1,17 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="placement" +SERVICE_NAME_DEFAULT="placement" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment # NOTE: These are framework-specific defaults; adjust if your environment uses different paths. @@ -19,12 +19,14 @@ GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" + +# Define the Global Overrides directory used in the original script GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE -# NOTE: Ensure this file exists and contains an entry for SERVICE_NAME. +# NOTE: Ensure this file exists and contains an entry for SERVICE_NAME_DEFAULT. VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" if [ ! -f "$VERSION_FILE" ]; then @@ -32,15 +34,48 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() @@ -63,7 +98,7 @@ fi # Include all YAML files from the GLOBAL configuration directory # NOTE: Files here override base settings and are applied before service-specific ones. if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then - echo "Including overrides from global config directory:" + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -71,7 +106,7 @@ if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES_DIR" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory @@ -90,13 +125,9 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely # NOTE: This array contains OpenStack-specific secret retrievals and MUST be updated -# with the necessary --set arguments for your target SERVICE_NAME. +# with the necessary --set arguments for your target SERVICE_NAME_DEFAULT. set_args=( # Keystone endpoint passwords --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" @@ -116,7 +147,7 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -128,7 +159,7 @@ helm_command=( # Post-renderer configuration # NOTE: Update the path and args if your service uses a different kustomization overlay. --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -138,4 +169,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-postgres-operator.sh b/bin/install-postgres-operator.sh index 05b6185e..4a0b5d06 100755 --- a/bin/install-postgres-operator.sh +++ b/bin/install-postgres-operator.sh @@ -1,45 +1,77 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="postgres-operator" +SERVICE_NAME_DEFAULT="postgres-operator" SERVICE_NAMESPACE="postgres-system" # Helm -HELM_REPO_NAME="postgres-operator-charts" -HELM_REPO_URL="https://opensource.zalando.com/postgres-operator/charts/postgres-operator" +HELM_REPO_NAME_DEFAULT="postgres-operator-charts" +HELM_REPO_URL_DEFAULT="https://opensource.zalando.com/postgres-operator/charts/postgres-operator" # Base directories provided by the environment -# NOTE: These are framework-specific defaults; adjust if your environment uses different paths. GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Read the desired chart version from VERSION_FILE -# NOTE: Ensure this file exists and contains an entry for SERVICE_NAME. VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" +# Read the desired chart version from VERSION_FILE if [ ! -f "$VERSION_FILE" ]; then echo "Error: helm-chart-versions.yaml not found at $VERSION_FILE" >&2 exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() @@ -62,7 +94,7 @@ fi # Include all YAML files from the custom SERVICE configuration directory # NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then - echo "Including overrides from service config directory:" + echo "Including overrides from service config directory: $SERVICE_CUSTOM_OVERRIDES" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -70,24 +102,17 @@ if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then fi done else - echo "Warning: Service config directory not found: $SERVICE_CUSTOM_OVERRIDES" + echo "Warning: Service overrides directory not found: $SERVICE_CUSTOM_OVERRIDES" fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely -# NOTE: This array contains OpenStack-specific secret retrievals and MUST be updated -# with the necessary --set arguments for your target SERVICE_NAME. -# This is empty for postgres-operator. set_args=() helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -99,7 +124,7 @@ helm_command=( # Post-renderer configuration # NOTE: Update the path and args if your service uses a different kustomization overlay. --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -109,4 +134,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-prometheus-blackbox-exporter.sh b/bin/install-prometheus-blackbox-exporter.sh index af0b02c9..ce36e5bb 100755 --- a/bin/install-prometheus-blackbox-exporter.sh +++ b/bin/install-prometheus-blackbox-exporter.sh @@ -1,27 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="prometheus-blackbox-exporter" +SERVICE_NAME_DEFAULT="prometheus-blackbox-exporter" SERVICE_NAMESPACE="prometheus" # Helm -HELM_REPO_NAME="prometheus-community" -HELM_REPO_URL="https://prometheus-community.github.io/helm-charts" +HELM_REPO_NAME_DEFAULT="prometheus-community" +HELM_REPO_URL_DEFAULT="https://prometheus-community.github.io/helm-charts" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${SERVICE_BASE_OVERRIDES:-$GENESTACK_BASE_DIR/base-helm-configs/$SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${SERVICE_CUSTOM_OVERRIDES:-$GENESTACK_OVERRIDES_DIR/helm-configs/$SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Read the desired chart version from VERSION_FILE +# NOTE: Ensure this file exists and contains an entry for SERVICE_NAME_DEFAULT. VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" if [ ! -f "$VERSION_FILE" ]; then @@ -29,62 +30,101 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" -# Prepare an array to collect --values arguments -values_args=() +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi -# Base Override Files +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" + +# Prepare an array to collect -f arguments +overrides_args=() + +# Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then - echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" - for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do - # Check that there is at least one match - if [[ -e "$file" ]]; then - echo " - $file" - values_args+=("--values" "$file") - fi - done + echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" + for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do + # Check that there is at least one match + if [[ -e "$file" ]]; then + echo " - $file" + overrides_args+=("-f" "$file") + fi + done else - echo "Warning: Base override directory not found: $SERVICE_BASE_OVERRIDES" + echo "Warning: Base override directory not found: $SERVICE_BASE_OVERRIDES" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then - echo "Including overrides from config directory:" - for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do - if [[ -e "$file" ]]; then - echo " - $file" - values_args+=("--values" "$file") - fi - done + echo "Including overrides from service config directory:" + for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do + if [[ -e "$file" ]]; then + echo " - $file" + overrides_args+=("-f" "$file") + fi + done else - echo "Warning: Config directory not found: $SERVICE_CUSTOM_OVERRIDES" + echo "Warning: Service config directory not found: $SERVICE_CUSTOM_OVERRIDES" fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update +# Collect all --set arguments, executing commands and quoting safely +set_args=() + helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME"/"$SERVICE_NAME" - --create-namespace --namespace="$SERVICE_NAMESPACE" --timeout 10m + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" + --namespace="$SERVICE_NAMESPACE" + --timeout 120m + --create-namespace - "${values_args[@]}" + "${overrides_args[@]}" + "${set_args[@]}" # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" + "$@" ) @@ -93,4 +133,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-prometheus-mysql-exporter.sh b/bin/install-prometheus-mysql-exporter.sh index a98d8bb3..a610f73f 100755 --- a/bin/install-prometheus-mysql-exporter.sh +++ b/bin/install-prometheus-mysql-exporter.sh @@ -1,27 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="prometheus-mysql-exporter" +SERVICE_NAME_DEFAULT="prometheus-mysql-exporter" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="prometheus-community" -HELM_REPO_URL="https://prometheus-community.github.io/helm-charts" +HELM_REPO_NAME_DEFAULT="prometheus-community" +HELM_REPO_URL_DEFAULT="https://prometheus-community.github.io/helm-charts" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Read the desired chart version from VERSION_FILE +# NOTE: Ensure this file exists and contains an entry for SERVICE_NAME_DEFAULT. VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" if [ ! -f "$VERSION_FILE" ]; then @@ -29,15 +30,48 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() @@ -73,16 +107,13 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely + set_args=() helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -93,7 +124,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -103,4 +134,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-prometheus-postgres-exporter.sh b/bin/install-prometheus-postgres-exporter.sh index a9cc8a64..5eefb5b2 100755 --- a/bin/install-prometheus-postgres-exporter.sh +++ b/bin/install-prometheus-postgres-exporter.sh @@ -1,27 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="prometheus-postgres-exporter" +SERVICE_NAME_DEFAULT="prometheus-postgres-exporter" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="prometheus-community" -HELM_REPO_URL="https://prometheus-community.github.io/helm-charts" +HELM_REPO_NAME_DEFAULT="prometheus-community" +HELM_REPO_URL_DEFAULT="https://prometheus-community.github.io/helm-charts" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Read the desired chart version from VERSION_FILE +# NOTE: Ensure this file exists and contains an entry for SERVICE_NAME_DEFAULT. VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" if [ ! -f "$VERSION_FILE" ]; then @@ -29,15 +30,48 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() @@ -73,16 +107,12 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely set_args=() helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -93,7 +123,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -103,4 +133,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-prometheus-pushgateway.sh b/bin/install-prometheus-pushgateway.sh index 7df11bf3..bd16824a 100755 --- a/bin/install-prometheus-pushgateway.sh +++ b/bin/install-prometheus-pushgateway.sh @@ -1,27 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="prometheus-pushgateway" +SERVICE_NAME_DEFAULT="prometheus-pushgateway" SERVICE_NAMESPACE="prometheus" # Helm -HELM_REPO_NAME="prometheus-community" -HELM_REPO_URL="https://prometheus-community.github.io/helm-charts" +HELM_REPO_NAME_DEFAULT="prometheus-community" +HELM_REPO_URL_DEFAULT="https://prometheus-community.github.io/helm-charts" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${SERVICE_BASE_OVERRIDES:-$GENESTACK_BASE_DIR/base-helm-configs/$SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${SERVICE_CUSTOM_OVERRIDES:-$GENESTACK_OVERRIDES_DIR/helm-configs/$SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Read the desired chart version from VERSION_FILE +# NOTE: Ensure this file exists and contains an entry for SERVICE_NAME_DEFAULT. VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" if [ ! -f "$VERSION_FILE" ]; then @@ -29,20 +30,54 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() -# Include all YAML files from the BASE configuration directory +# Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -57,8 +92,9 @@ else fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then - echo "Including overrides from config directory:" + echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -66,25 +102,29 @@ if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then fi done else - echo "Warning: Config directory not found: $SERVICE_CUSTOM_OVERRIDES" + echo "Warning: Service config directory not found: $SERVICE_CUSTOM_OVERRIDES" fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update +# Collect all --set arguments, executing commands and quoting safely +set_args=() + helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME"/"$SERVICE_NAME" - --create-namespace --namespace="$SERVICE_NAMESPACE" --timeout 10m + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" + --namespace="$SERVICE_NAMESPACE" + --timeout 120m + --create-namespace "${overrides_args[@]}" + "${set_args[@]}" # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" + "$@" ) @@ -93,4 +133,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-prometheus-rabbitmq-exporter.sh b/bin/install-prometheus-rabbitmq-exporter.sh index 815f8418..87cae013 100755 --- a/bin/install-prometheus-rabbitmq-exporter.sh +++ b/bin/install-prometheus-rabbitmq-exporter.sh @@ -1,27 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="prometheus-rabbitmq-exporter" +SERVICE_NAME_DEFAULT="prometheus-rabbitmq-exporter" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="prometheus-community" -HELM_REPO_URL="https://prometheus-community.github.io/helm-charts" +HELM_REPO_NAME_DEFAULT="prometheus-community" +HELM_REPO_URL_DEFAULT="https://prometheus-community.github.io/helm-charts" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Read the desired chart version from VERSION_FILE +# NOTE: Ensure this file exists and contains an entry for SERVICE_NAME_DEFAULT. VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" if [ ! -f "$VERSION_FILE" ]; then @@ -29,15 +30,48 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() @@ -73,16 +107,12 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely set_args=() helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -93,7 +123,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -103,4 +133,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-prometheus-snmp-exporter.sh b/bin/install-prometheus-snmp-exporter.sh index fde229e9..e038fb37 100755 --- a/bin/install-prometheus-snmp-exporter.sh +++ b/bin/install-prometheus-snmp-exporter.sh @@ -1,27 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="prometheus-snmp-exporter" +SERVICE_NAME_DEFAULT="prometheus-snmp-exporter" SERVICE_NAMESPACE="prometheus" # Helm -HELM_REPO_NAME="prometheus-community" -HELM_REPO_URL="https://prometheus-community.github.io/helm-charts" +HELM_REPO_NAME_DEFAULT="prometheus-community" +HELM_REPO_URL_DEFAULT="https://prometheus-community.github.io/helm-charts" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${SERVICE_BASE_OVERRIDES:-$GENESTACK_BASE_DIR/base-helm-configs/$SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${SERVICE_CUSTOM_OVERRIDES:-$GENESTACK_OVERRIDES_DIR/helm-configs/$SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Read the desired chart version from VERSION_FILE +# NOTE: Ensure this file exists and contains an entry for SERVICE_NAME_DEFAULT. VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" if [ ! -f "$VERSION_FILE" ]; then @@ -29,20 +30,54 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() -# Include all YAML files from the BASE configuration directory +# Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -57,8 +92,9 @@ else fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then - echo "Including overrides from config directory:" + echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -66,25 +102,29 @@ if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then fi done else - echo "Warning: Config directory not found: $SERVICE_CUSTOM_OVERRIDES" + echo "Warning: Service config directory not found: $SERVICE_CUSTOM_OVERRIDES" fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update +# Collect all --set arguments, executing commands and quoting safely +set_args=() + helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME"/"$SERVICE_NAME" - --create-namespace --namespace="$SERVICE_NAMESPACE" --timeout 10m + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" + --namespace="$SERVICE_NAMESPACE" + --timeout 120m + --create-namespace "${overrides_args[@]}" + "${set_args[@]}" # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" + "$@" ) @@ -93,4 +133,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-redis-operator.sh b/bin/install-redis-operator.sh index 5ebb9c10..459b94db 100755 --- a/bin/install-redis-operator.sh +++ b/bin/install-redis-operator.sh @@ -1,25 +1,26 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="redis-replication" +SERVICE_NAME_DEFAULT="redis-replication" SERVICE_NAMESPACE="redis-systems" +OPERATOR_NAME_DEFAULT="redis-operator" # Helm -HELM_REPO_NAME="ot-helm" -HELM_REPO_URL="https://ot-container-kit.github.io/helm-charts/" +HELM_REPO_NAME_DEFAULT="ot-helm" +HELM_REPO_URL_DEFAULT="https://ot-container-kit.github.io/helm-charts" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/redis-operator-replication" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/redis-operator-replication" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" @@ -42,22 +43,58 @@ echo "Found version for redis-operator: $REDIS_OPERATOR_VERSION" SERVICE_VERSION=$(grep 'redis-replication:' "$VERSION_FILE" | sed 's/.*redis-replication: *//') if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + OPERATOR_NAME=$(yq eval '.chart.operator_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${OPERATOR_NAME:=$OPERATOR_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + OPERATOR_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$OPERATOR_NAME" + REPLICATION_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" + +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + OPERATOR_CHART_PATH="$HELM_REPO_NAME/$OPERATOR_NAME" + REPLICATION_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi -# Helm Repository and Operator/CRD Installation -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] OPERATOR_NAME=$OPERATOR_NAME" +echo "[DEBUG] OPERATOR_CHART_PATH=$OPERATOR_CHART_PATH" +echo "[DEBUG] REPLICATION_CHART_PATH=$REPLICATION_CHART_PATH" echo "Installing Redis Operator (Step 1 of 2)..." helm upgrade --install \ --namespace="$SERVICE_NAMESPACE" \ --create-namespace \ - redis-operator \ - "$HELM_REPO_NAME/redis-operator" \ + "$OPERATOR_NAME_DEFAULT" \ + "$OPERATOR_CHART_PATH" \ --version "${REDIS_OPERATOR_VERSION}" # Prepare an array to collect -f arguments @@ -81,7 +118,7 @@ fi # Include all YAML files from the custom SERVICE configuration directory # NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then - echo "Including overrides from service config directory:" + echo "Including overrides from service config directory: $SERVICE_CUSTOM_OVERRIDES" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -89,7 +126,7 @@ if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then fi done else - echo "Warning: Service config directory not found: $SERVICE_CUSTOM_OVERRIDES" + echo "Warning: Service overrides directory not found: $SERVICE_CUSTOM_OVERRIDES" fi echo @@ -99,7 +136,7 @@ set_args=() helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$REPLICATION_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -110,7 +147,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) diff --git a/bin/install-redis-sentinel.sh b/bin/install-redis-sentinel.sh index f6672944..48fd9be5 100755 --- a/bin/install-redis-sentinel.sh +++ b/bin/install-redis-sentinel.sh @@ -1,48 +1,83 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="redis-sentinel" +SERVICE_NAME_DEFAULT="redis-sentinel" SERVICE_NAMESPACE="redis-systems" # Helm -HELM_REPO_NAME="ot-helm" -HELM_REPO_URL="https://ot-container-kit.github.io/helm-charts/" +HELM_REPO_NAME_DEFAULT="ot-helm" +HELM_REPO_URL_DEFAULT="https://ot-container-kit.github.io/helm-charts/" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${SERVICE_BASE_OVERRIDES:-$GENESTACK_BASE_DIR/base-helm-configs/$SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${SERVICE_CUSTOM_OVERRIDES:-$GENESTACK_OVERRIDES_DIR/helm-configs/$SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" # Read the desired chart version from VERSION_FILE VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml" +# Read the desired chart version from VERSION_FILE if [ ! -f "$VERSION_FILE" ]; then echo "Error: helm-chart-versions.yaml not found at $VERSION_FILE" >&2 exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -57,8 +92,9 @@ else fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then - echo "Including overrides from config directory:" + echo "Including overrides from service config directory: $SERVICE_CUSTOM_OVERRIDES" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -66,25 +102,29 @@ if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then fi done else - echo "Warning: Config directory not found: $SERVICE_CUSTOM_OVERRIDES" + echo "Warning: Service overrides directory not found: $SERVICE_CUSTOM_OVERRIDES" fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update +# Collect all --set arguments, executing commands and quoting safely +set_args=() + helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME"/"$SERVICE_NAME" - --create-namespace --namespace="$SERVICE_NAMESPACE" --timeout 120m + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" + --namespace="$SERVICE_NAMESPACE" + --timeout 120m + --create-namespace "${overrides_args[@]}" + "${set_args[@]}" # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" + "$@" ) @@ -93,4 +133,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-service-template.sh b/bin/install-service-template.sh index ec478b67..2e544010 100755 --- a/bin/install-service-template.sh +++ b/bin/install-service-template.sh @@ -1,25 +1,27 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="" +SERVICE_NAME_DEFAULT="" SERVICE_NAMESPACE="" # Helm -HELM_REPO_NAME="" -HELM_REPO_URL="" +HELM_REPO_NAME_DEFAULT="" +HELM_REPO_URL_DEFAULT="" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" + +# Define the Global Overrides directory used in the original script GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE @@ -30,20 +32,54 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() # Include all YAML files from the BASE configuration directory +# NOTE: Files in this directory are included first. if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES" for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do @@ -58,8 +94,9 @@ else fi # Include all YAML files from the GLOBAL configuration directory +# NOTE: Files here override base settings and are applied before service-specific ones. if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then - echo "Including overrides from global config directory:" + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -67,10 +104,11 @@ if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES_DIR" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory +# NOTE: Files here have the highest precedence. if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then echo "Including overrides from service config directory:" for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do @@ -85,10 +123,6 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely # In this section, you will include any additional helm commands (--set) that are # needed to configure the service correctly @@ -98,7 +132,7 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -109,7 +143,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -119,4 +153,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file diff --git a/bin/install-zaqar.sh b/bin/install-zaqar.sh index 6dfaf4be..7c0016b6 100755 --- a/bin/install-zaqar.sh +++ b/bin/install-zaqar.sh @@ -1,25 +1,28 @@ #!/bin/bash -# Description: Fetches the version for SERVICE_NAME from the specified +# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified # YAML file and executes a helm upgrade/install command with dynamic values files. # Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval) # shellcheck disable=SC2124,SC2145,SC2294 # Service -SERVICE_NAME="zaqar" +# The service name is used for both the release name and the chart name. +SERVICE_NAME_DEFAULT="zaqar" SERVICE_NAMESPACE="openstack" # Helm -HELM_REPO_NAME="openstack-helm" -HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm" +HELM_REPO_NAME_DEFAULT="openstack-helm" +HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm" # Base directories provided by the environment GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}" GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}" # Define service-specific override directories based on the framework -SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}" -SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}" +SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}" +SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}" + +# Define the Global Overrides directory used in the original script GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides" # Read the desired chart version from VERSION_FILE @@ -30,15 +33,49 @@ if [ ! -f "$VERSION_FILE" ]; then exit 1 fi -# Extract version dynamically using the SERVICE_NAME variable -SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//") +# Extract version dynamically using the SERVICE_NAME_DEFAULT variable +SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//") if [ -z "$SERVICE_VERSION" ]; then - echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2 + echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2 exit 1 fi -echo "Found version for $SERVICE_NAME: $SERVICE_VERSION" +echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION" + +# Load chart metadata from custom override YAML if defined +for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do + if [ -f "$yaml_file" ]; then + HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file") + HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file") + SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file") + break # use the first match and stop + fi +done + +# Fallback to defaults if variables not set +: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}" +: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}" +: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}" + + +# Determine Helm chart path +if [[ "$HELM_REPO_URL" == oci://* ]]; then + # OCI registry path + HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME" +else + # --- Helm Repository and Execution --- + helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed + helm repo update + HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME" +fi + + +# Debug output +echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL" +echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME" +echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME" +echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH" # Prepare an array to collect -f arguments overrides_args=() @@ -61,7 +98,7 @@ fi # Include all YAML files from the GLOBAL configuration directory # NOTE: Files here override base settings and are applied before service-specific ones. if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then - echo "Including overrides from global config directory:" + echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR" for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do if [[ -e "$file" ]]; then echo " - $file" @@ -69,7 +106,7 @@ if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then fi done else - echo "Warning: Global config directory not found: $GLOBAL_OVERRIDES_DIR" + echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR" fi # Include all YAML files from the custom SERVICE configuration directory @@ -88,10 +125,6 @@ fi echo -# --- Helm Repository and Execution --- -helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" -helm repo update - # Collect all --set arguments, executing commands and quoting safely set_args=( --set "endpoints.identity.auth.admin.password=$(kubectl --namespace openstack get secret keystone-admin -o jsonpath='{.data.password}' | base64 -d)" @@ -108,7 +141,7 @@ set_args=( helm_command=( - helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME" + helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH" --version "${SERVICE_VERSION}" --namespace="$SERVICE_NAMESPACE" --timeout 120m @@ -119,7 +152,7 @@ helm_command=( # Post-renderer configuration --post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh" - --post-renderer-args "$SERVICE_NAME/overlay" + --post-renderer-args "$SERVICE_NAME_DEFAULT/overlay" "$@" ) @@ -129,4 +162,4 @@ printf '%q ' "${helm_command[@]}" echo # Execute the command directly from the array -"${helm_command[@]}" +"${helm_command[@]}" \ No newline at end of file