#!/usr/bin/env bash
# 用途：部署或更新 Postgres（Secret / PVC / Deployment / Service）

set -euo pipefail

BASE_DIR="$(cd "$(dirname "$0")" && pwd)"
MANIFESTS="$BASE_DIR/manifests"

echo "部署 Postgres 中..."

kubectl apply -f "$MANIFESTS/postgres-secret.yaml"
kubectl apply -f "$MANIFESTS/postgres-pvc.yaml"
kubectl apply -f "$MANIFESTS/postgres-deployment.yaml"
kubectl apply -f "$MANIFESTS/postgres-service.yaml"

echo "完成，等待 Pod 就緒..."
kubectl wait --for=condition=ready pod -l app=postgres --timeout=120s

echo "Postgres 已啟動"

