# T93 manifest — 이번 실측(2026-07-05, homelab)에 적용된 리소스 정의.
#
# 원본 정의는 번들 랩 킷 files/lab/ 의 00~30.yaml + dr-scenarios/ 다(이 verify 폴더 기준 ../../lab/).
# run.sh -> setup.sh + run-scenario.sh 가 아래를 apply 했다.
#
# ── 이번 실측에서 발견/치환된 구체값 ────────────────────────────────────────
#   cluster domain      = homelab.local        (coredns Corefile 에서 자동 발견 — cluster.local 아님)
#   backend FQDN        = backend.conn-lab.svc.homelab.local  (client outbound cluster = outbound|8080||...)
#   blackhole auto-VIP  = 240.240.0.12         (client sidecar DNS proxy 가 auto-allocate; 실 endpoint 는 198.51.100.10)
#   client pod          = client-574475c99d-htkfj (k8s-worker1)   backend pod = backend-75564b7d74-mfljn
#
# 인프라(00-namespace / 10-backend / 20-client / 30-blackhole)는 files/lab/ 원본 그대로 적용됐다
# (분량상 여기 재수록 생략 — 번들 킷이 정본). 아래에는 "실험 변수"인 DR 시나리오(dr-scenarios/)를
# 실제 적용된 그대로 인라인한다. run-scenario.sh 는 한 번에 하나만 남기고(conn-dr / conn-blackhole-dr
# 이름 재사용) apply 해 같은 host 다중 DR 스택을 피한다.
#
# ⚠ S6 필수 전제 2가지(둘 다 files/lab/ 에 반영돼 있음):
#   (a) client sidecar DNS capture+auto-allocate — fortio 는 커넥트 전 DNS 조회를 하는데
#       blackhole.lab.internal(resolution:STATIC)은 클러스터 DNS 에 없어 NXDOMAIN 이면 트래픽이
#       Envoy 에 닿기 전 abort 된다. DNS 프록시가 이를 가로채 VIP 를 돌려줘야 커넥트가 성립한다.
#   (b) blackhole endpoint = 198.51.100.10 (RFC5737 TEST-NET-2) — default route 로 SYN 이 실제
#       발송되나 무응답 → connectTimeout 발동. (Class E 240/4 는 route 부재로 즉시 ENETUNREACH →
#       connect_fail 로 빠져 connect_timeout 이 안 잡힌다.)
---
# [S1] tcp.maxConnections:1  -> circuit_breakers.thresholds[].max_connections
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata: { name: conn-dr, namespace: conn-lab }
spec:
  host: backend
  trafficPolicy:
    connectionPool:
      tcp: { maxConnections: 1 }
---
# [S2] +http.http1MaxPendingRequests:1  -> +circuit_breakers.thresholds[].max_pending_requests
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata: { name: conn-dr, namespace: conn-lab }
spec:
  host: backend
  trafficPolicy:
    connectionPool:
      tcp:  { maxConnections: 1 }
      http: { http1MaxPendingRequests: 1 }
---
# [S3] http.maxRequestsPerConnection:1  -> HttpProtocolOptions.common_http_protocol_options.max_requests_per_connection
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata: { name: conn-dr, namespace: conn-lab }
spec:
  host: backend
  trafficPolicy:
    connectionPool:
      http: { maxRequestsPerConnection: 1 }
---
# [S4] http.idleTimeout:2s  -> common_http_protocol_options.idle_timeout
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata: { name: conn-dr, namespace: conn-lab }
spec:
  host: backend
  trafficPolicy:
    connectionPool:
      http: { idleTimeout: 2s }
---
# [S5] tcp.maxConnectionDuration:5s  -> common_http_protocol_options.max_connection_duration (HTTP 클러스터 경로)
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata: { name: conn-dr, namespace: conn-lab }
spec:
  host: backend
  trafficPolicy:
    connectionPool:
      tcp: { maxConnectionDuration: 5s }
---
# [S6] tcp.connectTimeout:1s (host: blackhole)  -> Cluster.connect_timeout
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata: { name: conn-blackhole-dr, namespace: conn-lab }
spec:
  host: blackhole.lab.internal
  trafficPolicy:
    connectionPool:
      tcp: { connectTimeout: 1s }
---
# [S7-full] config 검증: tcpKeepalive + maxRetries:2 + h2UpgradePolicy:UPGRADE + maxConcurrentStreams:64
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata: { name: conn-dr, namespace: conn-lab }
spec:
  host: backend
  trafficPolicy:
    connectionPool:
      tcp:
        tcpKeepalive: { time: 300s, interval: 30s, probes: 3 }
      http:
        maxRetries: 2
        h2UpgradePolicy: UPGRADE
        maxConcurrentStreams: 64
---
# [S7c] h2UpgradePolicy:UPGRADE 만 (maxConcurrentStreams 미설정 시 값 관측용)
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata: { name: conn-dr, namespace: conn-lab }
spec:
  host: backend
  trafficPolicy:
    connectionPool:
      http: { h2UpgradePolicy: UPGRADE }
---
# [S7b] useClientProtocol:true (use_downstream_protocol_config; h2UpgradePolicy 무력화)
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata: { name: conn-dr, namespace: conn-lab }
spec:
  host: backend
  trafficPolicy:
    connectionPool:
      http: { useClientProtocol: true }
