| |
| |
| |
|
|
| param( |
| [switch]$SkipPortForward, |
| [int]$GrafanaPort = 3000 |
| ) |
|
|
| Write-Host "=== AntiAtropos Local Deploy ===" -ForegroundColor Cyan |
| Write-Host "" |
|
|
| |
| Write-Host "[1/5] Checking Kind cluster..." -ForegroundColor Yellow |
| $cluster = kubectl config current-context 2>$null |
| if ($cluster -notmatch "antiatropos") { |
| Write-Host "WARNING: Current context is '$cluster', expected 'kind-antiatropos-local'. Proceed anyway? [Y/n]" |
| $r = Read-Host |
| if ($r -eq 'n') { exit 1 } |
| } |
|
|
| |
| Write-Host "[2/5] Deploying workload pods..." -ForegroundColor Yellow |
| kubectl create ns prod-sre 2>&1 | Out-Null |
| kubectl create ns monitoring 2>&1 | Out-Null |
| kubectl apply -f "$PSScriptRoot\deploy\local-laptop.yaml" |
| Write-Host " Waiting for workloads to be ready..." |
| kubectl wait --for=condition=ready pod -l app --all -n prod-sre --timeout=120s 2>$null |
| Write-Host " Workloads ready." |
|
|
| |
| Write-Host "[3/5] Deploying Prometheus..." -ForegroundColor Yellow |
| $promRelease = helm list -n monitoring -q 2>$null | Select-String "prometheus" |
| if ($promRelease) { |
| helm upgrade prometheus prometheus-community/prometheus -n monitoring -f "$PSScriptRoot\deploy\prometheus-helm-values.yaml" |
| } else { |
| helm install prometheus prometheus-community/prometheus -n monitoring -f "$PSScriptRoot\deploy\prometheus-helm-values.yaml" |
| } |
| Write-Host " Waiting for Prometheus server..." |
| kubectl wait --for=condition=ready pod -l "app.kubernetes.io/name=prometheus" -n monitoring --timeout=120s 2>$null |
| Write-Host " Prometheus ready." |
|
|
| |
| Write-Host "[4/5] Deploying Grafana..." -ForegroundColor Yellow |
| |
| kubectl delete configmap grafana-dashboards -n monitoring 2>$null |
| kubectl create configmap grafana-dashboards -n monitoring --from-file="$PSScriptRoot\deploy\grafana\provisioning\dashboards\json\" |
|
|
| $grafRelease = helm list -n monitoring -q 2>$null | Select-String "grafana" |
| if ($grafRelease) { |
| helm upgrade grafana grafana/grafana -n monitoring -f "$PSScriptRoot\deploy\grafana-helm-values.yaml" |
| } else { |
| helm install grafana grafana/grafana -n monitoring -f "$PSScriptRoot\deploy\grafana-helm-values.yaml" |
| } |
| Write-Host " Waiting for Grafana..." |
| kubectl wait --for=condition=ready pod -l "app.kubernetes.io/name=grafana" -n monitoring --timeout=120s 2>$null |
| Write-Host " Grafana ready." |
|
|
| |
| Write-Host "[5/5] Grafana port-forward..." -ForegroundColor Yellow |
| if (-not $SkipPortForward) { |
| |
| $existing = Get-NetTCPConnection -LocalPort $GrafanaPort -ErrorAction SilentlyContinue 2>$null |
| if ($existing) { |
| $pid = $existing.OwningProcess |
| Stop-Process -Id $pid -Force -ErrorAction SilentlyContinue 2>$null |
| Start-Sleep -Seconds 1 |
| } |
|
|
| Write-Host " Starting port-forward on localhost:$GrafanaPort..." |
| $proc = Start-Process -PassThru -NoNewWindow kubectl -ArgumentList "port-forward","-n","monitoring","svc/grafana","${GrafanaPort}:80" |
|
|
| Start-Sleep -Seconds 2 |
| |
| try { |
| $null = Invoke-WebRequest -Uri "http://localhost:$GrafanaPort/api/health" -UseBasicParsing -TimeoutSec 5 |
| Write-Host "" |
| Write-Host "=== Deploy Complete ===" -ForegroundColor Green |
| Write-Host " Grafana: http://localhost:$GrafanaPort (admin / antiatropos)" |
| Write-Host " Dashboards: AntiAtropos Overview, AntiAtropos Live Control Plane" |
| Write-Host " Port-forward PID: $($proc.Id)" |
| Write-Host "" |
| Write-Host "To stop port-forward: Stop-Process -Id $($proc.Id)" |
| } catch { |
| Write-Host "WARNING: Port-forward started but Grafana not reachable yet. Try: kubectl port-forward -n monitoring svc/grafana ${GrafanaPort}:80" |
| } |
| } else { |
| Write-Host "" |
| Write-Host "=== Deploy Complete ===" -ForegroundColor Green |
| Write-Host " To access Grafana: kubectl port-forward -n monitoring svc/grafana ${GrafanaPort}:80" |
| } |
|
|