#!/usr/bin/env bash # T67 - sidecar mode에서 같은 포트 숫자가 4개의 서로 다른 layer # (capture/virtual listener/cluster/endpoint)로 분해되는지 확인 # # NOTE: 이 클러스터는 실제 kubeadm clusterDomain=homelab.local 이지만, # istiod의 proxy.clusterDomain은 기본값 cluster.local로 남아있어 # Envoy 클러스터 이름의 FQDN suffix는 svc.cluster.local 이다. # (환경 전역 현상, kubectl exec client -- cat /etc/resolv.conf 로 확인 가능) # 이 스크립트는 실제로 동작하는 suffix(svc.cluster.local)를 사용한다. set -euo pipefail NS="istio-vt-t67" DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cleanup() { kubectl delete namespace "$NS" --wait=false --ignore-not-found >/dev/null 2>&1 || true } trap cleanup EXIT kubectl create namespace "$NS" --dry-run=client -o yaml | kubectl apply -f - kubectl label namespace "$NS" istio-injection=enabled --overwrite kubectl apply -n "$NS" -f "$DIR/manifest.yaml" kubectl -n "$NS" wait --for=condition=Ready pod/client --timeout=90s kubectl -n "$NS" rollout status deploy/echo --timeout=90s sleep 5 echo "== layer1: capture listener (0.0.0.0:15001) ==" istioctl proxy-config listener client."$NS" --port 15001 -o json | jq '.[0].name' echo "== layer2: virtual listener for Service port 80 ==" istioctl proxy-config listener client."$NS" --port 80 -o json | jq '.[0].name' echo "== layer3: cluster keyed by Service port 80 ==" istioctl proxy-config cluster client."$NS" --fqdn echo."$NS".svc.cluster.local -o json | jq '.[0].name' echo "== layer4: endpoint uses targetPort 8080 ==" istioctl proxy-config endpoint client."$NS" --cluster "outbound|80||echo.${NS}.svc.cluster.local"