Skip to main content
  1. Archives/

Istio Ambient 모드에서의 Envoy Config 톺아보기

·330 words

In-Mesh Workload를 destination으로 하는 요청에 대해서, envoy 의 어떤 동작을 거쳐 destination에 도달하는지 이해하기 위함. 이 과정에서 HBONE 프로토콜을 활용한 secure tunneling이 생성되는 과정을 이해할 수 있도록 함.

Intro #

도메인 api.channel.io 로 들어온 HTTPS 요청이 게이트웨이를 통과해 Pod까지 전달되는 과정을 단계별로 짚어나갑니다 (in Envoy config dump).

가정: Istio Gateway → Waypoint를 거쳐서 → Pod로 트래픽이 들어옴. (istio.io/ingress-use-waypoint label 사용)

Envoy Architecture:

  • Listener → Route → Cluster → Endpoint

1. Active Listener #

listener name: 0.0.0.0_443

  • listener_filter: HttpConnectionManager입니다. HTTP 수준에서 라우팅 정책을 설정 → Route Discovery Service(rds)
  • route_config: http.443 적용

+) static listener에는 0.0.0.0_150210.0.0.0_15090이 있음.

2. Dynamic Route Config #

  • Virtual Host: api.channel.io
  • Matched Cluster: outbound|8080||ch-public.channel.svc.cluster.local

3. Dynamic Active Cluster Config #

  • name: outbound|8080||ch-public.channel.svc.cluster.local

해당 Envoy cluster의 transport_socket_mathes에는 다음 matches 명시

  1. match.tunnel: httphbone: use envoy.transport_sockets.internal_upstream
  2. match.tlsMode: istiotlsMode-istio: use envoy.transport_sockets.tls
  3. default(no match) → tlsMode-disabled: use envoy.transport_sockets.raw_buffer

Istio Ambient mesh에 포함된 pod들은 metadata에 envoy.transport_socket_match: { "tunnel": "http" }가 명시되어 있음. 반대로, destination이 mesh에 포함되어 있지 않은 pod인 경우에는 raw_buffer로 트래픽을 pod로 보낼 수 있도록 함.


Reference:

4. Dynamic Endpoint Config #

ch-public의 endpoints

  • envoy_internal_address.endpoint_id: <POD IP>:15008
  • envoy_internal_address.service_listener_name: "connect_originate"
- metadata
	- filter_metadata
		- envoy.filters.listener.original_dst
			- local: `<Service IP>:<Service Port>`
			- waypoint: `<Waypoint IP>:15008`

Envoy endpoint에서 다시 connect_originate 라는 internal_listener로 이어짐.


Reference:

5. Active Listener Config (connect_originate) #

Listener Config에 connect_originate라는 listener가 존재함. 여기에서 filter로는 HTTPConnectionManager가 아닌 tcp_proxy를 사용. connect_originate%DOWNSTREAM_LOCAL_ADDRESS%를 연결함.


Reference:

6. Dynamic Active Cluster Config (connect_originate) #

  • type: ORIGINAL_DST

connect_originate 클러스터는 Original destination 타입의 특수한 클러스터.

  • downstream metadata로부터 upstream host를 동적으로 결정
  • EDS(Endpoint Discovery Service) 설정 없이 동작
  • original_dst_lb_config에서 port를 15008로 override하여 ztunnel(or waypoint)의 HBONE 포트를 향하도록 설정.

클러스터의 transport socket 설정은 UpstreamTlsContext.

  • ALPN 프로토콜: h2 (HTTP/2)
  • mTLS 인증: SPIFFE ID를 사용한 상호 인증

Internal listener는 다음과 같은 과정을 통해 최종 연결을 수행합니다

  1. TCP Proxy 생성: connect_originate 클러스터의 15008 포트를 대상으로 TCP Proxy 생성
  2. HBONE 터널링: mTLS + HTTP/2 CONNECT 기반의 secure tunnel 설정
  3. Authority 헤더: :authority 헤더를 %DOWNSTREAM_LOCAL_ADDRESS%로 설정하여 원래 의도한 ip:port로 전달


Reference: