From 1c2f0762d6bc949c803710f53f6e2e7f2c622cfc Mon Sep 17 00:00:00 2001 From: Venkat Date: Tue, 7 Jul 2026 15:14:14 +0000 Subject: [PATCH 1/4] feat: install kube-prometheus-stack CRDs during argocd install Replicates the kube-prometheus-stack-crds ArgoCD app from platform-helm-chart-platform via kubectl: the chart version is read from VERSIONS/glueops.yaml (kube_prometheus_stack_version, added by GlueOps/terraform-module-cloud-multy-prerequisites#648), the CRD folder is sparse-cloned from prometheus-community/helm-charts at that tag, and applied server-side (the prometheus CRDs are too large for client-side apply, mirroring the app's Replace=true). Co-Authored-By: Claude Fable 5 --- .devcontainer/tools/captain_utils.sh | 29 +++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.devcontainer/tools/captain_utils.sh b/.devcontainer/tools/captain_utils.sh index b57f52d9a1..e032d2f623 100755 --- a/.devcontainer/tools/captain_utils.sh +++ b/.devcontainer/tools/captain_utils.sh @@ -89,6 +89,33 @@ handle_platform_upgrades() { done } +# Installs the kube-prometheus-stack CRDs, replicating the kube-prometheus-stack-crds +# ArgoCD app from platform-helm-chart-platform. The chart version comes from +# VERSIONS/glueops.yaml (kube_prometheus_stack_version) like the other components. +# Server-side apply is used because the prometheus CRDs are too large for client-side +# apply (mirrors the app's Replace=true). +install_kube_prometheus_stack_crds() { + local kps_version crds_ref crd + if [ "$environment" = "production" ]; then + kps_version=$(yq '.versions[] | select(.name == "kube_prometheus_stack_version") | .version' VERSIONS/glueops.yaml) + else + kps_version=$(curl -sf "https://raw.githubusercontent.com/GlueOps/platform-helm-chart-platform/main/templates/application-kube-prometheus-stack-crds.yaml" | yq '.spec.source.targetRevision' | sed 's/^kube-prometheus-stack-//') + fi + if [ -z "$kps_version" ]; then + gum style --bold --foreground 196 "❌ kube_prometheus_stack_version not found in VERSIONS/glueops.yaml. Re-run terraform with an updated terraform-module-cloud-multy-prerequisites to regenerate it." + return 1 + fi + crds_ref="kube-prometheus-stack-${kps_version}" + gum style --bold --foreground 212 "Installing kube-prometheus-stack CRDs (${crds_ref}):" + local crds_dir + crds_dir=$(mktemp -d) + git -c advice.detachedHead=false clone --quiet --depth 1 --branch "$crds_ref" --filter=blob:none --sparse \ + https://github.com/prometheus-community/helm-charts.git "$crds_dir" + git -C "$crds_dir" sparse-checkout set --no-cone charts/kube-prometheus-stack/charts/crds/crds + kubectl apply --server-side --force-conflicts -R -f "$crds_dir/charts/kube-prometheus-stack/charts/crds/crds" + rm -rf "$crds_dir" +} + handle_argocd() { if [ "$environment" = "production" ]; then argocd_version=`yq '.versions[] | select(.name == "argocd_helm_chart_version") | .version' VERSIONS/glueops.yaml` @@ -123,7 +150,7 @@ handle_argocd() { local argocd_crd_versions=`v($(helm search repo argo/argo-cd --versions -o json | jq --arg chart_helm_version "$version" -r '.[] | select(.version == $chart_helm_version).app_version' | sed 's/^v//'))` fi chosen_crd_version=$(gum choose "${argocd_crd_versions[@]}" "Back") - pre_commands="kubectl apply -k \"https://github.com/argoproj/argo-cd/manifests/crds?ref=$chosen_crd_version\" && helm repo update" + pre_commands="kubectl apply -k \"https://github.com/argoproj/argo-cd/manifests/crds?ref=$chosen_crd_version\" && helm repo update && install_kube_prometheus_stack_crds" # Check if user wants to go back if [ "$chosen_crd_version" = "Back" ]; then return From f2e051ef2835c884cd51d9054ce89d87c4c4685b Mon Sep 17 00:00:00 2001 From: Venkat Date: Tue, 7 Jul 2026 15:35:12 +0000 Subject: [PATCH 2/4] feat: echo copy-pastable kube-prometheus-stack CRD install commands The command block is printed before being eval'd so users can copy it to re-run or debug (the set -x trace alone references a temp dir that is deleted afterwards, so it is not re-runnable as copied). Co-Authored-By: Claude Fable 5 --- .devcontainer/tools/captain_utils.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.devcontainer/tools/captain_utils.sh b/.devcontainer/tools/captain_utils.sh index e032d2f623..d4e001311c 100755 --- a/.devcontainer/tools/captain_utils.sh +++ b/.devcontainer/tools/captain_utils.sh @@ -106,14 +106,18 @@ install_kube_prometheus_stack_crds() { return 1 fi crds_ref="kube-prometheus-stack-${kps_version}" - gum style --bold --foreground 212 "Installing kube-prometheus-stack CRDs (${crds_ref}):" - local crds_dir - crds_dir=$(mktemp -d) - git -c advice.detachedHead=false clone --quiet --depth 1 --branch "$crds_ref" --filter=blob:none --sparse \ - https://github.com/prometheus-community/helm-charts.git "$crds_dir" - git -C "$crds_dir" sparse-checkout set --no-cone charts/kube-prometheus-stack/charts/crds/crds - kubectl apply --server-side --force-conflicts -R -f "$crds_dir/charts/kube-prometheus-stack/charts/crds/crds" - rm -rf "$crds_dir" + local install_cmds + install_cmds=$(cat < Date: Tue, 7 Jul 2026 15:37:09 +0000 Subject: [PATCH 3/4] feat: echo copy-pastable helm commands for argocd and platform installs Replaces the set -x traces around the helm diff/upgrade commands and the argocd pre-commands with a clean echo of the exact command string before it is eval'd, so users can copy it to re-run or debug (e.g. swap 'helm diff upgrade' for 'helm template'). Co-Authored-By: Claude Fable 5 --- .devcontainer/tools/captain_utils.sh | 48 ++++++++++++---------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/.devcontainer/tools/captain_utils.sh b/.devcontainer/tools/captain_utils.sh index d4e001311c..79aa3b60cd 100755 --- a/.devcontainer/tools/captain_utils.sh +++ b/.devcontainer/tools/captain_utils.sh @@ -69,23 +69,21 @@ handle_platform_upgrades() { echo "chosen version: $version for $chart_name" helm_diff_cmd="helm diff --color upgrade \"$component\" \"$chart_name\" --version \"$version\" -f \"$target_file\" -f \"$overrides_file\" -n \"$namespace\" --allow-unreleased" - - set -x + + gum style --bold --foreground 212 "Running diff with the following command (copy to re-run or debug, e.g. swap 'diff --color upgrade' for 'template'):" + echo "$helm_diff_cmd" eval "$helm_diff_cmd | gum pager" # Execute the main helm diff command gum style --bold --foreground 212 "✅ Diff complete." - set +x - + if ! gum confirm "Apply upgrade"; then return fi - - # Running helm diff command - gum style --bold --foreground 212 "The following commands will be executed:" - - set -x - helm upgrade --install "$component" "$chart_name" --version "$version" -f "$target_file" -f "$overrides_file" -n "$namespace" --create-namespace - set +x - return + + helm_upgrade_cmd="helm upgrade --install \"$component\" \"$chart_name\" --version \"$version\" -f \"$target_file\" -f \"$overrides_file\" -n \"$namespace\" --create-namespace" + gum style --bold --foreground 212 "The following commands will be executed (copy to re-run or debug):" + echo "$helm_upgrade_cmd" + eval "$helm_upgrade_cmd" + return done } @@ -160,35 +158,31 @@ handle_argocd() { return fi - set -x + gum style --bold --foreground 212 "Running diff with the following command (copy to re-run or debug, e.g. swap 'diff --color upgrade' for 'template'):" + echo "$helm_diff_cmd" eval "$helm_diff_cmd | gum pager" # Execute the main helm diff command gum style --bold --foreground 212 "✅ Diff complete." - set +x - + if ! gum confirm "Apply upgrade"; then return fi - - # Running helm diff command - gum style --bold --foreground 212 "The following commands will be executed:" - + # New: Execute pre_commands if defined if [ -n "$pre_commands" ] && [ -n "$chosen_crd_version" ]; then - gum style --bold --foreground 212 "Executing pre-commands for $component:" - set -x + gum style --bold --foreground 212 "Executing pre-commands for $component (copy to re-run or debug):" + echo "$pre_commands" eval "$pre_commands" if [ $? -ne 0 ]; then gum style --bold --foreground 196 "❌ Pre-commands failed. Aborting diff." - set +x continue # Allow user to retry or go back fi - set +x gum style --bold --foreground 212 "✅ Pre-commands complete." fi - set -x - helm upgrade --install "$component" "$chart_name" --version "$version" -f "$target_file" -n "$namespace" --create-namespace --skip-crds - set +x - return + helm_upgrade_cmd="helm upgrade --install \"$component\" \"$chart_name\" --version \"$version\" -f \"$target_file\" -n \"$namespace\" --create-namespace --skip-crds" + gum style --bold --foreground 212 "The following commands will be executed (copy to re-run or debug):" + echo "$helm_upgrade_cmd" + eval "$helm_upgrade_cmd" + return done } From 24d617dc9cb86b6a2bd61af4c459502a79eb2bdb Mon Sep 17 00:00:00 2001 From: Venkat Date: Tue, 7 Jul 2026 15:53:30 +0000 Subject: [PATCH 4/4] fix: address expert review findings on CRD install and pre-commands - Run pre_commands and install_kube_prometheus_stack_crds inside a tested condition so failures reach the retry/continue handler instead of set -e killing the whole session (the old bare eval made the $? check dead code). - Keep the echoed pre_commands fully copy-pastable by moving the CRD function call out of the string; the function prints its own self-contained block. - Chain the CRD block with && (fail-fast survives the suspended set -e) and clean up the temp dir on the failure path. - GIT_TERMINAL_PROMPT=0 so GitHub auth/rate-limit prompts fail fast instead of hanging. - Fix the helm template hint: --allow-unreleased is helm-diff-only and must be dropped when swapping to template. - Drop unused 'crd' local. Failure paths (missing version key, nonexistent tag, kubectl failure) and the success path verified with a stubbed harness: the menu loop survives, no temp dirs leak, echoed block matches what runs. Co-Authored-By: Claude Fable 5 --- .devcontainer/tools/captain_utils.sh | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/.devcontainer/tools/captain_utils.sh b/.devcontainer/tools/captain_utils.sh index 79aa3b60cd..59dda03ca2 100755 --- a/.devcontainer/tools/captain_utils.sh +++ b/.devcontainer/tools/captain_utils.sh @@ -70,7 +70,7 @@ handle_platform_upgrades() { helm_diff_cmd="helm diff --color upgrade \"$component\" \"$chart_name\" --version \"$version\" -f \"$target_file\" -f \"$overrides_file\" -n \"$namespace\" --allow-unreleased" - gum style --bold --foreground 212 "Running diff with the following command (copy to re-run or debug, e.g. swap 'diff --color upgrade' for 'template'):" + gum style --bold --foreground 212 "Running diff with the following command (copy to re-run or debug, e.g. swap 'diff --color upgrade' for 'template' and drop '--allow-unreleased'):" echo "$helm_diff_cmd" eval "$helm_diff_cmd | gum pager" # Execute the main helm diff command gum style --bold --foreground 212 "✅ Diff complete." @@ -93,7 +93,7 @@ handle_platform_upgrades() { # Server-side apply is used because the prometheus CRDs are too large for client-side # apply (mirrors the app's Replace=true). install_kube_prometheus_stack_crds() { - local kps_version crds_ref crd + local kps_version crds_ref crds_dir="" if [ "$environment" = "production" ]; then kps_version=$(yq '.versions[] | select(.name == "kube_prometheus_stack_version") | .version' VERSIONS/glueops.yaml) else @@ -106,16 +106,20 @@ install_kube_prometheus_stack_crds() { crds_ref="kube-prometheus-stack-${kps_version}" local install_cmds install_cmds=$(cat <