#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
ENV_FILE="${1:-$ROOT/k8s/regional/regions.env}"
OUT="${2:-$ROOT/k8s/regional/rendered}"
"$ROOT/scripts/render-regional-k8s.sh" "$ENV_FILE" "$OUT"
kubectl apply -f "$OUT/service.yaml"
kubectl apply -f "$OUT/pdb.yaml"
kubectl apply -f "$OUT/deployment-ord.yaml"
kubectl apply -f "$OUT/deployment-iad.yaml"
kubectl apply -f "$OUT/hpa-ord.yaml"
kubectl apply -f "$OUT/hpa-iad.yaml"
kubectl rollout status -f "$OUT/deployment-ord.yaml" --timeout=10m
kubectl rollout status -f "$OUT/deployment-iad.yaml" --timeout=10m
kubectl get pods -l app="$(grep '^APP_NAME=' "$ENV_FILE" | cut -d= -f2)-regional" -o wide
