#!/usr/bin/env bash # 用途:查看 Postgres 狀態與連線資訊 set -euo pipefail echo echo "=== Pod ===" kubectl get pod -l app=postgres -o wide echo echo "=== Service ===" kubectl get svc postgres echo echo "=== PVC ===" kubectl get pvc postgres-pvc echo echo "=== NodePort 連線 ===" NODE_IPS=$(kubectl get nodes -o jsonpath='{range .items[*]}{.status.addresses[?(@.type=="InternalIP")].address}{" "}{end}') PORT=$(kubectl get svc postgres -o jsonpath='{.spec.ports[0].nodePort}') for ip in $NODE_IPS; do echo "- $ip:$PORT" done