#!/bin/sh set -eu context=${1:?usage: deploy/observability/install.sh KUBERNETES_CONTEXT} observability=item-atlas-observability config_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) kubectl --context "$context" get namespace item-atlas-staging >/dev/null kubectl --context "$context" -n "$observability" get secret atlas-grafana-admin -o name >/dev/null kubectl --context "$context" apply --dry-run=server -f "$config_dir/serviceaccount.yaml" -f "$config_dir/rbac.yaml" >/dev/null kubectl --context "$context" apply -f "$config_dir/serviceaccount.yaml" -f "$config_dir/rbac.yaml" if [ -z "${ATLAS_CHART_DIR:-}" ]; then helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo add grafana-community https://grafana-community.github.io/helm-charts helm repo add grafana https://grafana.github.io/helm-charts helm repo update prometheus-community grafana-community grafana fi install_chart() { component="$1" chart="$2" version="$3" shift 3 if [ -n "${ATLAS_CHART_DIR:-}" ]; then chart="$ATLAS_CHART_DIR/$component-$version.tgz" fi helm upgrade --install "atlas-$component" "$chart" --version "$version" \ --kube-context "$context" --namespace "$observability" --atomic --wait --timeout 8m \ -f "$config_dir/$component.yaml" "$@" } install_chart prometheus prometheus-community/prometheus 30.0.0 install_chart loki grafana-community/loki 21.6.0 install_chart tempo grafana-community/tempo 2.4.0 install_chart alloy grafana/alloy 1.16.0 --set-file "alloy.configMap.content=$config_dir/config.alloy" install_chart grafana grafana-community/grafana 14.5.1