#!/usr/bin/env bash # T69: VirtualService route의 weight는 RDS route의 weighted_clusters로 그대로 번역되는지 검증 set -euo pipefail NS=istio-vt-t69 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" MANIFEST="${SCRIPT_DIR}/manifest.yaml" cleanup() { echo "--- cleanup: deleting namespace ${NS} ---" kubectl delete namespace "${NS}" --wait=false --ignore-not-found } trap cleanup EXIT echo "--- create namespace ${NS} (istio-injection=enabled) ---" kubectl create namespace "${NS}" kubectl label namespace "${NS}" istio-injection=enabled --overwrite echo "--- apply manifest ---" kubectl apply -f "${MANIFEST}" echo "--- wait for workloads ---" kubectl -n "${NS}" wait --for=condition=Ready pod/client --timeout=90s kubectl -n "${NS}" wait --for=condition=available deploy/weight-echo-v1 deploy/weight-echo-v2 --timeout=60s sleep 5 echo "--- spec jq query (as originally written; may return null due to vhost index bug -- see notes) ---" istioctl proxy-config route "client.${NS}" -o json | \ jq --arg ns "${NS}" '[.[] | select(.virtualHosts[]?.domains[]? == ("weight-echo." + $ns + ".svc.homelab.local"))][0].virtualHosts[0].routes[0].route.weightedClusters.clusters' echo "--- corrected jq query (selects the actual matching virtualHost, not just index 0) ---" istioctl proxy-config route "client.${NS}" -o json | \ jq --arg ns "${NS}" '[.[].virtualHosts[]? | select(.domains[]? == ("weight-echo." + $ns + ".svc.homelab.local"))][0].routes[0].route.weightedClusters.clusters' echo "--- done ---"