37 lines
1.4 KiB
Bash
37 lines
1.4 KiB
Bash
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
# Esegue kubectl apply per ogni sottodirectory di kubernetes separatamente
|
|
|
|
ENVIRONMENT="${1:-dev}"
|
|
|
|
YAML_DIR="kubernetes"
|
|
|
|
# Valore di alert_notification_email per l'ambiente (ultima occorrenza in env/<env>/*.env)
|
|
ALERT_EMAIL=$(cat "env/$ENVIRONMENT"/*.env 2>/dev/null | grep -E '^[[:space:]]*alert_notification_email[[:space:]]*=' | tail -n 1 | sed -E 's/^[^=]*=//' | tr -d '\r"'"'"'[:space:]' || true)
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Deploy di tutti i manifest Kubernetes
|
|
# ---------------------------------------------------------------------------
|
|
find "$YAML_DIR" -type d | while read DIR; do
|
|
if ls "$DIR"/*.yaml 1> /dev/null 2>&1; then
|
|
if [ "$(basename "$DIR")" = "monitoring" ]; then
|
|
if [ -z "$ALERT_EMAIL" ]; then
|
|
echo "alert_notification_email non valorizzata per l'ambiente $ENVIRONMENT: deploy di $DIR saltato."
|
|
continue
|
|
fi
|
|
echo "Deploy delle risorse di monitoring nella directory $DIR con kubeconfig dedicato..."
|
|
kubectl --kubeconfig=/root/work/pipeline/kc apply -f "$DIR"
|
|
else
|
|
echo "Deploy delle risorse nella directory $DIR..."
|
|
kubectl --kubeconfig=./kubeconfig apply -f "$DIR"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
echo "Deploy completato di tutte le directory YAML."
|
|
|
|
echo "Eseguo check su endpoint da pubblicare"
|
|
/root/work/pipeline/addlistener.sh "$ENVIRONMENT"
|