Skip to content

Commit f6bfc22

Browse files
committed
Add support for custom Helm chart repo, URL, and service name in all installer
scripts Extend this capability to all install-.sh scripts before merging it into the main branch and converted mariadb & memcached installer to support dynamic variables.
1 parent f13be59 commit f6bfc22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2277
-845
lines changed

bin/install-argocd.sh

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
#!/bin/bash
2-
# Description: Fetches the version for SERVICE_NAME from the specified
2+
# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified
33
# YAML file and executes a helm upgrade/install command with dynamic values files.
44

55
# Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval)
66
# shellcheck disable=SC2124,SC2145,SC2294
77

88
# Service
9-
SERVICE_NAME="argocd"
9+
SERVICE_NAME_DEFAULT="argocd"
1010
SERVICE_NAMESPACE="argocd"
1111

1212
# Helm
13-
HELM_REPO_NAME="bitnami"
14-
HELM_REPO_URL="https://charts.bitnami.com/bitnami"
13+
HELM_REPO_NAME_DEFAULT="bitnami"
14+
HELM_REPO_URL_DEFAULT="https://charts.bitnami.com/bitnami"
1515

1616
# Base directories provided by the environment
1717
GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}"
1818
GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}"
1919

2020
# Define service-specific override directories based on the framework
21-
SERVICE_BASE_OVERRIDES="${SERVICE_BASE_OVERRIDES:-$GENESTACK_BASE_DIR/base-helm-configs/$SERVICE_NAME}"
22-
SERVICE_CUSTOM_OVERRIDES="${SERVICE_CUSTOM_OVERRIDES:-$GENESTACK_OVERRIDES_DIR/helm-configs/$SERVICE_NAME}"
21+
SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}"
22+
SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}"
23+
24+
# Define the Global Overrides directory used in the original script
25+
GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides"
2326

2427
# Read the desired chart version from VERSION_FILE
2528
VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml"
@@ -29,20 +32,54 @@ if [ ! -f "$VERSION_FILE" ]; then
2932
exit 1
3033
fi
3134

32-
# Extract version dynamically using the SERVICE_NAME variable
33-
SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//")
35+
# Extract version dynamically using the SERVICE_NAME_DEFAULT variable
36+
SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//")
3437

3538
if [ -z "$SERVICE_VERSION" ]; then
36-
echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2
39+
echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2
3740
exit 1
3841
fi
3942

40-
echo "Found version for $SERVICE_NAME: $SERVICE_VERSION"
43+
echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION"
44+
45+
# Load chart metadata from custom override YAML if defined
46+
for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do
47+
if [ -f "$yaml_file" ]; then
48+
HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file")
49+
HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file")
50+
SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file")
51+
break # use the first match and stop
52+
fi
53+
done
54+
55+
# Fallback to defaults if variables not set
56+
: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}"
57+
: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}"
58+
: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}"
59+
60+
61+
# Determine Helm chart path
62+
if [[ "$HELM_REPO_URL" == oci://* ]]; then
63+
# OCI registry path
64+
HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME"
65+
else
66+
# --- Helm Repository and Execution ---
67+
helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed
68+
helm repo update
69+
HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME"
70+
fi
71+
72+
# Debug output
73+
echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL"
74+
echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME"
75+
echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME"
76+
echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH"
4177

4278
# Prepare an array to collect -f arguments
4379
overrides_args=()
4480

45-
# Base Override Files
81+
# Include all YAML files from the BASE configuration directory
82+
# NOTE: Files in this directory are included first.
4683
if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then
4784
echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES"
4885
for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do
@@ -57,30 +94,34 @@ else
5794
fi
5895

5996
# Include all YAML files from the custom SERVICE configuration directory
97+
# NOTE: Files here have the highest precedence.
6098
if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then
61-
echo "Including overrides from config directory:"
99+
echo "Including overrides from service config directory: $SERVICE_CUSTOM_OVERRIDES"
62100
for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do
63101
if [[ -e "$file" ]]; then
64102
echo " - $file"
65103
overrides_args+=("-f" "$file")
66104
fi
67105
done
68106
else
69-
echo "Warning: Config directory not found: $SERVICE_CUSTOM_OVERRIDES"
107+
echo "Warning: Service overrides directory not found: $SERVICE_CUSTOM_OVERRIDES"
70108
fi
71109

72110
echo
73111

74-
# --- Helm Repository and Execution ---
75-
helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL"
76-
helm repo update
112+
# Collect all --set arguments, executing commands and quoting safely
113+
set_args=()
114+
77115

78116
helm_command=(
79-
helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME"/"$SERVICE_NAME"
80-
--create-namespace --namespace="$SERVICE_NAMESPACE" --timeout 120m
117+
helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH"
81118
--version "${SERVICE_VERSION}"
119+
--namespace="$SERVICE_NAMESPACE"
120+
--timeout 120m
121+
--create-namespace
82122

83123
"${overrides_args[@]}"
124+
"${set_args[@]}"
84125

85126
# Post-renderer configuration
86127
--post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh"
@@ -93,4 +134,4 @@ printf '%q ' "${helm_command[@]}"
93134
echo
94135

95136
# Execute the command directly from the array
96-
"${helm_command[@]}"
137+
"${helm_command[@]}"

bin/install-barbican.sh

Lines changed: 59 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
#!/bin/bash
2-
# Description: Fetches the version for SERVICE_NAME from the specified
2+
# Description: Fetches the version for SERVICE_NAME_DEFAULT from the specified
33
# YAML file and executes a helm upgrade/install command with dynamic values files.
44

55
# Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval)
66
# shellcheck disable=SC2124,SC2145,SC2294
77

88
# Service
99
# The service name is used for both the release name and the chart name.
10-
SERVICE_NAME="barbican"
10+
SERVICE_NAME_DEFAULT="barbican"
1111
SERVICE_NAMESPACE="openstack"
1212

1313
# Helm
14-
HELM_REPO_NAME="openstack-helm"
15-
HELM_REPO_URL="https://tarballs.opendev.org/openstack/openstack-helm"
14+
HELM_REPO_NAME_DEFAULT="openstack-helm"
15+
HELM_REPO_URL_DEFAULT="https://tarballs.opendev.org/openstack/openstack-helm"
1616

1717
# Base directories provided by the environment
1818
GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}"
1919
GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}"
2020

2121
# Define service-specific override directories based on the framework
22-
SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}"
23-
SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}"
22+
SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME_DEFAULT}"
23+
SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME_DEFAULT}"
2424

2525
# Define the Global Overrides directory used in the original script
26-
GLOBAL_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides"
26+
GLOBAL_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides"
2727

2828
# Read the desired chart version from VERSION_FILE
2929
VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml"
@@ -33,20 +33,55 @@ if [ ! -f "$VERSION_FILE" ]; then
3333
exit 1
3434
fi
3535

36-
# Extract version dynamically.
37-
SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//")
36+
# Extract version dynamically using the SERVICE_NAME_DEFAULT variable
37+
SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME_DEFAULT}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME_DEFAULT}: *//")
3838

3939
if [ -z "$SERVICE_VERSION" ]; then
40-
echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2
40+
echo "Error: Could not extract version for '$SERVICE_NAME_DEFAULT' from $VERSION_FILE" >&2
4141
exit 1
4242
fi
4343

44-
echo "Found version for $SERVICE_NAME: $SERVICE_VERSION"
44+
echo "Found version for $SERVICE_NAME_DEFAULT: $SERVICE_VERSION"
45+
46+
# Load chart metadata from custom override YAML if defined
47+
for yaml_file in "${SERVICE_CUSTOM_OVERRIDES}"/*.yaml; do
48+
if [ -f "$yaml_file" ]; then
49+
HELM_REPO_URL=$(yq eval '.chart.repo_url // ""' "$yaml_file")
50+
HELM_REPO_NAME=$(yq eval '.chart.repo_name // ""' "$yaml_file")
51+
SERVICE_NAME=$(yq eval '.chart.service_name // ""' "$yaml_file")
52+
break # use the first match and stop
53+
fi
54+
done
55+
56+
# Fallback to defaults if variables not set
57+
: "${HELM_REPO_URL:=$HELM_REPO_URL_DEFAULT}"
58+
: "${HELM_REPO_NAME:=$HELM_REPO_NAME_DEFAULT}"
59+
: "${SERVICE_NAME:=$SERVICE_NAME_DEFAULT}"
60+
61+
62+
# Determine Helm chart path
63+
if [[ "$HELM_REPO_URL" == oci://* ]]; then
64+
# OCI registry path
65+
HELM_CHART_PATH="$HELM_REPO_URL/$HELM_REPO_NAME/$SERVICE_NAME"
66+
else
67+
# --- Helm Repository and Execution ---
68+
helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" # uncomment if needed
69+
helm repo update
70+
HELM_CHART_PATH="$HELM_REPO_NAME/$SERVICE_NAME"
71+
fi
72+
73+
74+
# Debug output
75+
echo "[DEBUG] HELM_REPO_URL=$HELM_REPO_URL"
76+
echo "[DEBUG] HELM_REPO_NAME=$HELM_REPO_NAME"
77+
echo "[DEBUG] SERVICE_NAME=$SERVICE_NAME"
78+
echo "[DEBUG] HELM_CHART_PATH=$HELM_CHART_PATH"
4579

4680
# Prepare an array to collect -f arguments
4781
overrides_args=()
4882

49-
# Base Override Files: Check the standard base directory.
83+
# Include all YAML files from the BASE configuration directory
84+
# NOTE: Files in this directory are included first.
5085
if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then
5186
echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES"
5287
for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do
@@ -60,38 +95,36 @@ else
6095
echo "Warning: Base override directory not found: $SERVICE_BASE_OVERRIDES"
6196
fi
6297

63-
# Include Global Overrides
64-
if [[ -d "$GLOBAL_OVERRIDES" ]]; then
65-
echo "Including global overrides from directory: $GLOBAL_OVERRIDES"
66-
for file in "$GLOBAL_OVERRIDES"/*.yaml; do
98+
# Include all YAML files from the GLOBAL configuration directory
99+
# NOTE: Files here override base settings and are applied before service-specific ones.
100+
if [[ -d "$GLOBAL_OVERRIDES_DIR" ]]; then
101+
echo "Including global overrides from directory: $GLOBAL_OVERRIDES_DIR"
102+
for file in "$GLOBAL_OVERRIDES_DIR"/*.yaml; do
67103
if [[ -e "$file" ]]; then
68104
echo " - $file"
69105
overrides_args+=("-f" "$file")
70106
fi
71107
done
72108
else
73-
echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES"
109+
echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES_DIR"
74110
fi
75111

76112
# Include all YAML files from the custom SERVICE configuration directory
113+
# NOTE: Files here have the highest precedence.
77114
if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then
78-
echo "Including overrides from config directory:"
115+
echo "Including overrides from service config directory:"
79116
for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do
80117
if [[ -e "$file" ]]; then
81118
echo " - $file"
82119
overrides_args+=("-f" "$file")
83120
fi
84121
done
85122
else
86-
echo "Warning: Config directory not found: $SERVICE_OVERRIDES"
123+
echo "Warning: Service config directory not found: $SERVICE_CUSTOM_OVERRIDES"
87124
fi
88125

89126
echo
90127

91-
# --- Helm Repository and Execution ---
92-
helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL"
93-
helm repo update
94-
95128
# Collect all --set arguments, executing commands and quoting safely
96129
set_args=(
97130
--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=(
106139

107140

108141
helm_command=(
109-
helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME"/"$SERVICE_NAME"
142+
helm upgrade --install "$SERVICE_NAME_DEFAULT" "$HELM_CHART_PATH"
110143
--version "${SERVICE_VERSION}"
111144
--namespace="$SERVICE_NAMESPACE"
112145
--timeout 120m
@@ -117,7 +150,7 @@ helm_command=(
117150

118151
# Post-renderer configuration
119152
--post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh"
120-
--post-renderer-args "$SERVICE_NAME/overlay"
153+
--post-renderer-args "$SERVICE_NAME_DEFAULT/overlay"
121154

122155
"$@"
123156
)
@@ -127,5 +160,4 @@ printf '%q ' "${helm_command[@]}"
127160
echo
128161

129162
# Execute the command directly from the array
130-
"${helm_command[@]}"
131-
163+
"${helm_command[@]}"

0 commit comments

Comments
 (0)