#!/bin/bash # Load shared libraries SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/../lib/init.sh" # Script to set up shared infrastructure services set -e echo "🏗️ Setting up shared infrastructure services..." # Check prerequisites command -v kubectl >/dev/null 2>&1 || { echo "❌ kubectl not found"; exit 1; } command -v helm >/dev/null 2>&1 || { echo "❌ helm not found"; exit 1; } # Configuration NAMESPACE="shared-services" REGISTRY_NAMESPACE="container-registry" echo "📋 Creating namespaces..." kubectl create namespace "$NAMESPACE" --dry-run=client -o yaml | kubectl apply -f - kubectl create namespace "$REGISTRY_NAMESPACE" --dry-run=client -o yaml | kubectl apply -f - echo "📦 Setting up Prometheus/Grafana..." # Add Prometheus Helm repo helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update # Install Prometheus Stack helm upgrade --install prometheus prometheus-community/kube-prometheus-stack \ --namespace "$NAMESPACE" \ --create-namespace \ --set prometheus.prometheusSpec.retention=30d \ --wait || echo "⚠️ Prometheus installation skipped (may already exist)" echo "📊 Setting up Loki for logging..." helm repo add grafana https://grafana.github.io/helm-charts helm repo update helm upgrade --install loki grafana/loki-stack \ --namespace "$NAMESPACE" \ --create-namespace \ --wait || echo "⚠️ Loki installation skipped (may already exist)" echo "🐳 Setting up container registry (Harbor)..." # Harbor setup would go here echo " → Harbor setup requires additional configuration" echo " → See: https://goharbor.io/docs/" echo "✅ Shared infrastructure setup initiated!" echo "" echo "📝 Next steps:" echo " 1. Configure Prometheus/Grafana dashboards" echo " 2. Set up Loki log aggregation" echo " 3. Deploy container registry" echo " 4. Configure monitoring alerts" echo " 5. Migrate projects to shared infrastructure"