#!/usr/bin/env bash # T92: 번들 랩 킷(files/lab/)만으로 DNS/GSLB resolution 재현 랩을 처음부터 끝까지 # (setup -> flip-test 3모드 -> cleanup) 재현할 수 있는지 라이브 검증한다. # # 검증하는 claim: # C1. 번들 킷만으로 setup -> test -> cleanup 전체 생애주기 재현 가능 # C2. STRICT_DNS flip(A->B) 시 사라진 host의 기존 커넥션 drain (세션 끊김) # C3. LOGICAL_DNS flip(A->B) 시 기존 세션 보존 (delta 0, who 불변) # C4. LOGICAL_DNS 는 pinned IP 가 죽어야 재연결 (flip 만으론 안 옮김) # # 전제: kubectl 현재 컨텍스트가 대상 클러스터(이 실측은 homelab, k8s 1.30.6 / Istio 1.30.0), # istioctl 사용 가능. 번들 킷은 이 파일 기준 ../../lab/ 에 있다. set -uo pipefail # 번들 랩 킷 경로 (verify/T92 에서 상대 경로로 lab/ 로 올라간다) SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" LAB="$(cd "$SCRIPT_DIR/../../lab" && pwd)" echo "LAB kit = $LAB" # ── 0. 기존 잔재 철거 (멱등) — 이 실측은 이전 랩 잔재가 살아있는 상태에서 시작했다 ── echo "[0/6] teardown any pre-existing dns-lab (bundle cleanup.sh; mid-lab idempotency test)" bash "$LAB/cleanup.sh" # ── 1. 번들 킷으로 fresh setup ── # setup.sh 가 하는 일: self-signed cert -> ns/secret -> cluster DNS ClusterIP 치환 후 lab-dns # -> backends -> lab-dns ClusterIP + cluster domain(coredns 에서 자동 발견) 치환 후 client # -> rollout 대기 -> GSLB 초기값 backend-a 로 addn 기록. # 핵심 함정: cluster domain 하드코딩 금지 — 이 클러스터는 homelab.local(cluster.local 아님). echo "[1/6] bundle setup.sh (fresh build)" bash "$LAB/setup.sh" # 확인: pods / dig / SE->cluster type 매핑 kubectl get ns dns-lab kubectl -n dns-lab get pods -o wide kubectl -n dns-lab exec deploy/netshoot -- dig +short gslb.lab.internal # -> backend-a ClusterIP # ── 2. STRICT mode1: flip 시 기존 커넥션 drain (세션 끊김) ── echo "[2/6] flip-test strict mode1" bash "$LAB/flip-test.sh" strict mode1 # 기대: membership_change +1, upstream_cx_destroy +2(=destroy_local, Envoy 능동 drain), # endpoint A->B 교체, who 는 flip 후 backend-b 로 전환, fortio Sockets 2 / 100% 200. # ── 3. LOGICAL mode1: flip 시 기존 세션 보존 ── echo "[3/6] flip-test logical mode1" bash "$LAB/flip-test.sh" logical mode1 # 기대: 3a->3b 델타 전부 0(membership_change/cx_destroy/cx_total 불변), who=backend-a 40초 유지. # 관측 함정: endpoint 덤프는 backend-b(새 IP)로 라벨 갱신되지만 응답 body 는 backend-a. # ── 4. LOGICAL mode3: flip 엔 유지, kill 순간 재연결 (트레이드오프) ── echo "[4/6] flip-test logical mode3 (60s load)" bash "$LAB/flip-test.sh" logical mode3 # 기대: FLIP 후에도 who=backend-a 유지 -> backend-a KILL 순간 who=backend-b 전환, # code!=200 0건(무손실), destroy_with_active_rq 0. # ── 5. cleanup ── echo "[5/6] bundle cleanup.sh" bash "$LAB/cleanup.sh" # ── 6. NotFound 재확인 ── echo "[6/6] confirm ns/dns-lab gone" kubectl get ns dns-lab # -> Error from server (NotFound) echo "done"