# 20 — Egress gateway **목표**: 메시 → 외부 송신을 단일 지점(egress gateway)으로 통제. ServiceEntry로 외부 등록, Sidecar scope로 가시성 제한, `REGISTRY_ONLY`로 미등록 외부 차단. ## manifest (적용 완료 — 2026-06-07 검증 PASS, HTTPS SNI passthrough) - `serviceentry-httpbin-ext.yaml` — httpbin.org:443 메시 레지스트리 등록(MESH_EXTERNAL/DNS) - `gateway-egress.yaml` — egress Gateway (selector `istio: egressgateway`, 443 TLS PASSTHROUGH) - `virtualservice-egress.yaml` — sleep → egress gateway → httpbin.org, 2단 SNI 라우팅 - `destinationrule-egress.yaml` — egress gateway subset `httpbin` - (예정) `sidecar-scope.yaml` — `mesh-test` egress 호스트 제한 (Sidecar 리소스) ## manifest (적용 완료 — 2026-06-08 검증 PASS, ISTIO_MUTUAL "HTTPS over mTLS") 별도 도메인 `edition.cnn.com`으로 추가(httpbin passthrough는 control 보존). sidecar↔egress 구간을 메시 mTLS로 감싸 egress gw가 호출 워크로드 SPIFFE 신원을 검증. 앱은 HTTPS end-to-end 유지(이중 TLS). - `serviceentry-cnn-ext.yaml` — edition.cnn.com:443 등록(TLS/DNS) - `gateway-egress-cnn-mtls.yaml` — egress Gateway, **port 15443 / `tls.mode: ISTIO_MUTUAL`** - `destinationrule-egress-cnn-mtls.yaml` — subset cnn, `ISTIO_MUTUAL` + `sni: edition.cnn.com` - `virtualservice-egress-cnn-mtls.yaml` — leg-1 `tls`/sniHosts→gw:15443, **leg-2 `tcp`**→cnn:443 > 두 함정(실측): ① 같은 443에 PASSTHROUGH(httpbin)+ISTIO_MUTUAL 공존 불가 → 포트 15443 분리. > ② 종단(ISTIO_MUTUAL) listener엔 `tls`/sniHosts 라우트가 0 chains로 omit됨 → leg-2를 `tcp`로. > 상세: `docs/test-reports/2026-06-08_egress-mtls-istio-mutual.md` ```bash # ISTIO_MUTUAL 경로 테스트 (200 + 앱 TLS end-to-end) kubectl -n mesh-test exec deploy/sleep -c sleep -- \ curl -sI -w "%{http_code} ssl_verify=%{ssl_verify_result}\n" https://edition.cnn.com/ # egress gw 15443 listener가 client cert 강제(메시 mTLS)인지 istioctl proxy-config listeners deploy/istio-egressgateway.istio-system -o json | grep -i requireClientCertificate ``` ## 핵심 검증 포인트 1. **경유 강제**: 외부 호출이 실제로 egress gateway를 지나는가 `istioctl proxy-config routes deploy/sleep.mesh-test` / egress gateway access log 확인 2. **차단**: `outboundTrafficPolicy: REGISTRY_ONLY` 에서 ServiceEntry 없는 외부 → 502/차단 3. **TLS origination**: 평문→egress에서 TLS 시작(선택) ## 테스트 ```bash # 등록된 외부 (경유 + 200) kubectl -n mesh-test exec deploy/sleep -c sleep -- curl -sI https://httpbin.org/get # egress gateway 로그에 요청 기록 확인 kubectl -n istio-system logs deploy/istio-egressgateway | tail # 미등록 외부 (REGISTRY_ONLY 차단 확인) kubectl -n mesh-test exec deploy/sleep -c sleep -- curl -s -o /dev/null -w "%{http_code}\n" https://example.org ``` ## 합격 기준 - 등록 외부: egress gateway 경유 + 200 - 미등록 외부: REGISTRY_ONLY 차단 - Sidecar scope 적용 시 sleep 프록시 cluster 목록 축소(`proxy-config clusters`) ## 산출물 - `docs/test-reports/2026-06-07_ingress-egress.md` - 관련 학습: `~/istio-md` 아카이브 `gw__note-eastwest-gateway-sni` / `gw__note-sidecar-scope`