diff --git a/.devcontainer/tools/captain_utils.sh b/.devcontainer/tools/captain_utils.sh index b57f52d9a1..59dda03ca2 100755 --- a/.devcontainer/tools/captain_utils.sh +++ b/.devcontainer/tools/captain_utils.sh @@ -69,26 +69,59 @@ 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' 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." - 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 } +# 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 crds_dir="" + 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}" + local install_cmds + install_cmds=$(cat <