LabHub
배우기 러닝패스 코스

Istio 심화 — 왜 그렇게 흐르는가 · DestinationRule 트래픽 정책이 클러스터가 되기까지 · 실습

트래픽 정책을 클러스터로 옮기고 넘치게 해 본다

LabHub 에서 이어서 보기

목표

DestinationRule 의 트래픽 정책을 Envoy 클러스터 필드로 번역하고, 이상치 감지와 서킷 브레이커가 실제로 어떻게 동작하는지 요청을 보내 센다.

왜 중요한가

트래픽 정책은 설정이 틀려서가 아니라 동작에 대한 기대가 틀려서 사고가 난다. 한도는 사이드카마다 세고, 이상치 감지는 사후 조치이며, 서브셋 정책은 부모를 덩어리째 덮어쓴다. 번역된 클러스터와 실제 동작을 한 번 보고 나면 설정 리뷰에서 이 세 가지를 바로 짚을 수 있다.

단계

1. /root/ist2-dr/dr.yaml 에 DestinationRule 을 쓰세요 — 이름 ratings, 네임스페이스 default, host ratings.default.svc.cluster.local. trafficPolicyloadBalancer.simple: LEAST_REQUEST, connectionPooltcp.maxConnections: 3·http.http1MaxPendingRequests: 2·http.http2MaxRequests: 5, outlierDetectionconsecutive5xxErrors: 2·interval: 5s·baseEjectionTime: 30s·maxEjectionPercent: 50. 서브셋은 v2(라벨 version: v2) 하나이고, 그 서브셋에만 trafficPolicy.connectionPool.tcp.maxConnections: 1 을 줍니다. istioctl validate 의 출력과 종료 코드를 /root/ist2-dr/01-validate.txt 에 담으세요(마지막 줄 rc=0).
2. /root/ist2-dr/02-map.txt 에 DestinationRule 필드가 Envoy 클러스터의 어느 필드가 되는지 일곱 줄로 적으세요. 한 줄은 <trafficPolicy 아래 경로>=<클러스터 아래 경로> 꼴이고, 점으로 이은 경로에 배열 첨자는 쓰지 않습니다. 왼쪽은 이 일곱 개입니다 — loadBalancer.simple, connectionPool.tcp.maxConnections, connectionPool.http.http1MaxPendingRequests, connectionPool.http.http2MaxRequests, outlierDetection.consecutive5xxErrors, outlierDetection.baseEjectionTime, outlierDetection.maxEjectionPercent.
3. /root/ist2-dr/pool.yaml 에 Envoy 설정을 쓰세요 — 관리 포트 9985, 리스너 127.0.0.1:10085 의 모든 경로를 클러스터 outbound|9080||ratings.default.svc.cluster.local 로. 그 클러스터는 엔드포인트 셋(127.0.0.1:8107, 127.0.0.1:8108, 127.0.0.1:8115)과 1단계의 부모 트래픽 정책을 2단계 대응표대로 옮긴 필드(lb_policy, circuit_breakers.thresholds 한 칸, outlier_detection — interval 도 함께)를 가집니다. envoy --mode validate 의 출력과 종료 코드를 /root/ist2-dr/03-validate.txt 에 담으세요(마지막 줄 rc=0).
4. 업스트림 셋을 띄우고(8107·8115ok, 8108fail) pool.yaml 로 Envoy 를 띄운 뒤, localhost:9985/config_dump?resource=static_clusters 에서 이 클러스터의 값을 뽑아 /root/ist2-dr/04-dump.txt 에 한 줄로 적으세요 — lb=<lb_policy> maxconn=<max_connections> pend=<max_pending_requests> req=<max_requests> c5xx=<consecutive_5xx> base=<base_ejection_time> pct=<max_ejection_percent>.
5. pool.yaml 로 Envoy 를 다시 띄운 직후 요청 30 번을 차례로 보내고, /root/ist2-dr/05-eject.txt 에 네 줄을 적으세요 — failed_requests=(30 번 중 503 을 받은 수), ejected=(/clusters 에서 health_flags 가 /failed_outlier_check 인 엔드포인트의 주소:포트), ejections_enforced_total=(통계 outlier_detection.ejections_enforced_total 의 값), ejections_active=(통계 outlier_detection.ejections_active 의 값).
6. pool.yaml/root/ist2-dr/pool-subset.yaml 로 복사하고 서브셋 v2 의 클러스터 outbound|9080|v2|ratings.default.svc.cluster.local(엔드포인트 127.0.0.1:8115)를 더하세요. Istio 가 1단계의 DestinationRule 로 만드는 것과 같게 — lb_policyoutlier_detection 은 부모와 같고, circuit_breakers.thresholds 는 서브셋의 connectionPool 으로 만듭니다: max_connections: 1, 그리고 서브셋이 정하지 않은 max_pending_requests·max_requests·max_retries 는 Istio 의 기본값 4294967295. 라우트는 접두사 /v2 를 이 클러스터로, 나머지는 그대로. 다시 띄운 뒤 /clustersdefault_priority 줄에서 읽어 /root/ist2-dr/06-subset.txtv2_max_connections=, v2_max_pending_requests=, default_max_pending_requests=(부모 클러스터의 값) 세 줄을 적으세요.
7. pool.yaml/root/ist2-dr/pool-cb.yaml 로 복사하고 클러스터 outbound|9080|slow|ratings.default.svc.cluster.local 를 더하세요 — 엔드포인트 127.0.0.1:8116(3초 걸려 답하는 업스트림), circuit_breakers.thresholdsmax_connections: 1, max_pending_requests: 1 (Istio 로는 tcp.maxConnections: 1, http.http1MaxPendingRequests: 1), 이상치 감지는 없음. 라우트는 접두사 /slow 를 이 클러스터로. 업스트림을 8116slow 로 띄우고 Envoy 를 --concurrency 1 로 다시 띄운 뒤, /slow 요청 다섯 개를 동시에 보내세요(& 로 띄우고 wait). /root/ist2-dr/07-overflow.txtok=(200 수), overflow_503=(503 수), pending_overflow=(slow 클러스터 통계 upstream_rq_pending_overflow 의 값) 세 줄을 적으세요.
8. /root/ist2-dr/08-report.mdlb_policy=, failures_before_eject=(5단계에서 빠지기 전에 맞은 503 수), v2_pending_limit=(6단계에서 본 v2 의 대기열 한도), overflow_status=(7단계에서 넘친 요청이 받은 코드) 네 줄을 적고, 그 아래 - 로 시작하는 설명을 네 줄 이상 적으세요.

참고

8단계

  1. 트래픽 정책이 든 DestinationRule 을 쓴다
  2. 필드 일곱 개의 대응표를 만든다
  3. 대응표대로 클러스터를 세운다
  4. config_dump 에서 여섯 값을 되읽는다
  5. 이상치 감지는 실패를 겪은 뒤에 뺀다
  6. 서브셋 정책은 덩어리째 덮어쓴다
  7. 서킷 브레이커가 실제로 열리는 것을 센다
  8. DestinationRule 번역표로 정리한다