Ssoon

1주차 : Istio 첫걸음 (5) - Observability 본문

Istio Hands-on Study [1기]

1주차 : Istio 첫걸음 (5) - Observability

구구달스 2025. 4. 12. 20:20
CloudNet@ 가시다님이 진행하는 Istio Hands-on Study [1기]

Istio Observability

Istio는 서비스들 사이의 통신을 감시하고, 자동으로 모니터링 데이터를 수집해주는 기능

🧱 왜 가능한가요?

  • Istio는 모든 서비스 옆에 '프록시(proxy)'를 같이 배치해요.
  • 이 프록시가 네트워크 트래픽을 가로채고 분석하니까,애플리케이션 코드 수정 없이도 트래픽과 성능을 볼 수 있습니다.

📊 Istio가 수집하는 데이터 종류

1. 기본 메트릭 (Top-Level Metrics)

Istio는 트래픽을 자동으로 분석해서 서비스 상태를 보여주는 기본적인 성능 지표를 제공합니다.

🛠 어떤 준비가 필요하나요?

  • 이미 Istio 사이드카 프록시가 앱에 주입되어 있고 Istio Ingress Gateway를 통해 외부에서 접근할 수 있게 설정되어 있다면 이제 메트릭을 수집해서 시각화할 수 있어요!

🔧 메트릭 수집 도구

  • Istio는 Prometheus와 Grafana 같은 도구를 함께 사용할 수 있어요:
Prometheus 메트릭 데이터를 수집하고 저장함
Grafana 수집된 데이터를 대시보드로 보여줌
Istio는 Prometheus와 Grafana 같은 도구와 함께 사용하면, 트래픽과 성능 데이터를 자동으로 수집해서 시각화
  • 초당 요청 수 (Requests per second)
  • 에러 수 (Failures)
  • 지연 시간 (Latency, 특히 tail latency - 느린 응답들)

🔎 이런 정보로 서비스의 건강 상태와 병목 구간을 파악할 수 있어요.

2. 분산 추적 (Distributed Tracing)

여러 서비스가 서로 통신할 때, 요청이 어디서 시작되어 어디까지 갔는지 추적하는 기술

🚀 Istio로 분산 추적을 어떻게 하나요?

  1. Istio는 트래픽을 자동으로 감지하고 추적 정보를 수집합니다.
  2. 설치 시 함께 제공되는 Jaeger 대시보드를 통해 추적 내역을 시각화할 수 있어요.

🧠 중요한 포인트

  • Istio가 서비스 간 추적 정보(Trace ID 등)를 자동으로 전달해줌
  • Jaeger/Zipkin 같은 툴이 시각화해줌
  • 그러나, 서비스 내부의 연결(logic)은 애플리케이션이 알려줘야 함
Istio는 Jaeger 같은 툴과 함께, 서비스 간 요청 흐름을 자동으로 추적하고 시각화해주는 분산 추적 기능을 제공
  • 어떤 서비스 호출이 얼마나 걸렸는지 추적 가능
  • 코드를 수정하지 않아도 Istio가 자동으로 Span(추적 단위) 을 생성해줘요

🔍 어느 서비스에서 느려졌는지 쉽게 파악 가능!

 

✅ 실습

  •  kind 클러스터에서 Istio 프록시(catalog, webapp, istio-ingressgateway)가 istiod와 정상적으로 동기화(SYNCED)된 상태
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ docker exec -it myk8s-control-plane istioctl proxy-status
NAME                                                  CLUSTER        CDS        LDS        EDS        RDS          ECDS         ISTIOD                      VERSION
catalog-6cf4b97d-5p442.istioinaction                  Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-7df6ffc78d-5swsh     1.17.8
istio-ingressgateway-996bc6bb6-vgg65.istio-system     Kubernetes     SYNCED     SYNCED     SYNCED     NOT SENT     NOT SENT     istiod-7df6ffc78d-5swsh     1.17.8
webapp-7685bcb84-mcmxv.istioinaction                  Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-7df6ffc78d-5swsh     1.17.8
  • Istio의 Gateway와 VirtualService를 정의하여 외부 트래픽을 webapp 서비스로 라우팅하는 설정
  • Gateway (outfitters-gateway):
    외부에서 오는 HTTP 요청을 80번 포트로 받아들이는 "문"을 만들어요.
    Istio의 ingressgateway를 사용해서 모든 호스트(*)의 트래픽을 처리해요.
  • VirtualService (webapp-virtualservice):
    Gateway로 들어온 트래픽을 webapp 서비스의 80번 포트로 보내는 "안내원" 역할이에요.
    모든 호스트(*)의 요청을 istioinaction 네임스페이스의 webapp으로 연결해요.
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ cat ch2/ingress-gateway.yaml
apiVersion: networking.istio.io/v1alpha3
kind: Gateway #Gateway는 외부에서 클러스터로 들어오는 트래픽을 처리하는 문 역할
metadata:
  name: outfitters-gateway
  namespace: istioinaction #Gateway가 속할 네임스페이스
spec:
  selector:
    istio: ingressgateway #외부 트래픽을 처음 받아들이는 Istio의 기본 게이트웨이 파드
  servers:
  - port:
      number: 80 #Gateway가 80번 포트(HTTP 기본 포트)로 트래픽을 받도록 설정
      name: http
      protocol: HTTP
    hosts: # Gateway가 처리할 호스트(도메인)를 정의
    - "*" #모든 호스트(*)에서 오는 요청을 받아들이겠다고 설정
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService #VirtualService는 Gateway로 들어온 트래픽을 어디로 보낼지(어떤 서비스로 라우팅할지) 결정하는 규칙
metadata:
  name: webapp-virtualservice
  namespace: istioinaction
spec:
  hosts: #VirtualService가 처리할 호스트(도메인)를 지정
  - "*" #모든 호스트(*)에서 오는 요청을 처리
  gateways: #VirtualService가 연결될 Gateway를 지정
  - outfitters-gateway #outfitters-gateway를 통해 들어오는 트래픽을 처리
  http:
  - route: #HTTP 요청을 어디로 보낼지 라우팅 규칙을 시작
    - destination: #트래픽을 보낼 목적지를 설정
        host: webapp #트래픽을 webapp 서비스로 보내겠다고 지정
        port:
          number: 80 #webapp 서비스의 80번 포트로 트래픽 전달
  • istioinaction 네임스페이스에서 Istio Gateway(outfitters-gateway)와 VirtualService(webapp-virtualservice)가 성공적으로 생성되었음
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ kubectl get gw,vs -n istioinaction
NAME                                             AGE
gateway.networking.istio.io/outfitters-gateway   44s

NAME                                                       GATEWAYS                 HOSTS   AGE
virtualservice.networking.istio.io/webapp-virtualservice   ["outfitters-gateway"]   ["*"]   44s
  • ISTIOIGW라는 변수를 설정 -> 이 변수는 Istio의 Ingress Gateway라는 특정 프록시를 가리킵니다.
  • WEBAPP라는 변수를 설정 -> 이 변수는 애플리케이션 파드을 가리킵니다.
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ docker exec -it myk8s-control-plane istioctl proxy-status
NAME                                                  CLUSTER        CDS        LDS        EDS        RDS        ECDS         ISTIOD                      VERSION
catalog-6cf4b97d-5p442.istioinaction                  Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED     NOT SENT     istiod-7df6ffc78d-5swsh     1.17.8
istio-ingressgateway-996bc6bb6-vgg65.istio-system     Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED     NOT SENT     istiod-7df6ffc78d-5swsh     1.17.8
webapp-7685bcb84-mcmxv.istioinaction                  Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED     NOT SENT     istiod-7df6ffc78d-5swsh     1.17.8
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ ISTIOIGW=istio-ingressgateway-996bc6bb6-vgg65.istio-system
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ WEBAPP=webapp-7685bcb84-mcmxv.istioinaction

💠 istio-ingressgateway 파드(외부 트래픽을 받는 게이트웨이)의 설정 상태

  • 서비스 목록 (SERVICE FQDN):
  • 포트 매핑 (ADDRESS PORT MATCH):
  • 라우팅 규칙 (NAME DOMAINS MATCH):
  • 인증서 상태 (RESOURCE NAME TYPE):
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ docker exec -it myk8s-control-plane istioctl proxy-config all $ISTIOIGW
SERVICE FQDN                                            PORT      SUBSET     DIRECTION     TYPE           DESTINATION RULE
BlackHoleCluster                                        -         -          -             STATIC       
agent                                                   -         -          -             STATIC       
catalog.istioinaction.svc.cluster.local                 80        -          outbound      EDS          
grafana.istio-system.svc.cluster.local                  3000      -          outbound      EDS          
istio-ingressgateway.istio-system.svc.cluster.local     80        -          outbound      EDS          
istio-ingressgateway.istio-system.svc.cluster.local     443       -          outbound      EDS          
istio-ingressgateway.istio-system.svc.cluster.local     15021     -          outbound      EDS          
istiod.istio-system.svc.cluster.local                   443       -          outbound      EDS          
istiod.istio-system.svc.cluster.local                   15010     -          outbound      EDS          
istiod.istio-system.svc.cluster.local                   15012     -          outbound      EDS          
istiod.istio-system.svc.cluster.local                   15014     -          outbound      EDS          
jaeger-collector.istio-system.svc.cluster.local         9411      -          outbound      EDS          
jaeger-collector.istio-system.svc.cluster.local         14250     -          outbound      EDS          
jaeger-collector.istio-system.svc.cluster.local         14268     -          outbound      EDS          
kiali.istio-system.svc.cluster.local                    9090      -          outbound      EDS          
kiali.istio-system.svc.cluster.local                    20001     -          outbound      EDS          
kube-dns.kube-system.svc.cluster.local                  53        -          outbound      EDS          
kube-dns.kube-system.svc.cluster.local                  9153      -          outbound      EDS          
kubernetes.default.svc.cluster.local                    443       -          outbound      EDS          
prometheus.istio-system.svc.cluster.local               9090      -          outbound      EDS          
prometheus_stats                                        -         -          -             STATIC       
sds-grpc                                                -         -          -             STATIC       
tracing.istio-system.svc.cluster.local                  80        -          outbound      EDS          
tracing.istio-system.svc.cluster.local                  16685     -          outbound      EDS          
webapp.istioinaction.svc.cluster.local                  80        -          outbound      EDS          
xds-grpc                                                -         -          -             STATIC       
zipkin                                                  -         -          -             STRICT_DNS   
zipkin.istio-system.svc.cluster.local                   9411      -          outbound      EDS          

ADDRESS PORT  MATCH DESTINATION
0.0.0.0 8080  ALL   Route: http.8080
0.0.0.0 15021 ALL   Inline Route: /healthz/ready*
0.0.0.0 15090 ALL   Inline Route: /stats/prometheus*

NAME          DOMAINS     MATCH                  VIRTUAL SERVICE
http.8080     *           /*                     webapp-virtualservice.istioinaction
              *           /healthz/ready*
              *           /stats/prometheus*

RESOURCE NAME     TYPE           STATUS     VALID CERT     SERIAL NUMBER                               NOT AFTER                NOT BEFORE
default           Cert Chain     ACTIVE     true           77748410043224152587897040189531781500      2025-04-13T09:20:41Z     2025-04-12T09:18:41Z
ROOTCA            CA             ACTIVE     true           288766384546012559812257962513943000525     2035-04-10T09:20:31Z     2025-04-12T09:20:31Z

💠 kind 클러스터에서 실행 중인 webapp 애플리케이션의 Istio 프록시 설정

  • 서비스 목록 (SERVICE FQDN):
  • 포트 매핑 (ADDRESS PORT MATCH):
  • 라우팅 규칙 (NAME DOMAINS MATCH):
  • 인증서 상태 (RESOURCE NAME TYPE):
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ docker exec -it myk8s-control-plane istioctl proxy-config all $WEBAPP
SERVICE FQDN                                            PORT      SUBSET     DIRECTION     TYPE             DESTINATION RULE
                                                        8080      -          inbound       ORIGINAL_DST 
BlackHoleCluster                                        -         -          -             STATIC       
InboundPassthroughClusterIpv4                           -         -          -             ORIGINAL_DST 
PassthroughCluster                                      -         -          -             ORIGINAL_DST 
agent                                                   -         -          -             STATIC       
catalog.istioinaction.svc.cluster.local                 80        -          outbound      EDS          
grafana.istio-system.svc.cluster.local                  3000      -          outbound      EDS          
istio-ingressgateway.istio-system.svc.cluster.local     80        -          outbound      EDS          
istio-ingressgateway.istio-system.svc.cluster.local     443       -          outbound      EDS          
istio-ingressgateway.istio-system.svc.cluster.local     15021     -          outbound      EDS          
istiod.istio-system.svc.cluster.local                   443       -          outbound      EDS          
istiod.istio-system.svc.cluster.local                   15010     -          outbound      EDS          
istiod.istio-system.svc.cluster.local                   15012     -          outbound      EDS          
istiod.istio-system.svc.cluster.local                   15014     -          outbound      EDS          
jaeger-collector.istio-system.svc.cluster.local         9411      -          outbound      EDS          
jaeger-collector.istio-system.svc.cluster.local         14250     -          outbound      EDS          
jaeger-collector.istio-system.svc.cluster.local         14268     -          outbound      EDS          
kiali.istio-system.svc.cluster.local                    9090      -          outbound      EDS          
kiali.istio-system.svc.cluster.local                    20001     -          outbound      EDS          
kube-dns.kube-system.svc.cluster.local                  53        -          outbound      EDS          
kube-dns.kube-system.svc.cluster.local                  9153      -          outbound      EDS          
kubernetes.default.svc.cluster.local                    443       -          outbound      EDS          
prometheus.istio-system.svc.cluster.local               9090      -          outbound      EDS          
prometheus_stats                                        -         -          -             STATIC       
sds-grpc                                                -         -          -             STATIC       
tracing.istio-system.svc.cluster.local                  80        -          outbound      EDS          
tracing.istio-system.svc.cluster.local                  16685     -          outbound      EDS          
webapp.istioinaction.svc.cluster.local                  80        -          outbound      EDS          
xds-grpc                                                -         -          -             STATIC       
zipkin                                                  -         -          -             STRICT_DNS   
zipkin.istio-system.svc.cluster.local                   9411      -          outbound      EDS          

ADDRESS     PORT  MATCH                                                                                           DESTINATION
10.200.1.10 53    ALL                                                                                             Cluster: outbound|53||kube-dns.kube-system.svc.cluster.local
0.0.0.0     80    Trans: raw_buffer; App: http/1.1,h2c                                                            Route: 80
0.0.0.0     80    ALL                                                                                             PassthroughCluster
10.200.1.1  443   ALL                                                                                             Cluster: outbound|443||kubernetes.default.svc.cluster.local
10.200.1.29 443   ALL                                                                                             Cluster: outbound|443||istio-ingressgateway.istio-system.svc.cluster.local
10.200.1.45 443   ALL                                                                                             Cluster: outbound|443||istiod.istio-system.svc.cluster.local
10.200.1.36 3000  Trans: raw_buffer; App: http/1.1,h2c                                                            Route: grafana.istio-system.svc.cluster.local:3000
10.200.1.36 3000  ALL                                                                                             Cluster: outbound|3000||grafana.istio-system.svc.cluster.local
0.0.0.0     9090  Trans: raw_buffer; App: http/1.1,h2c                                                            Route: 9090
0.0.0.0     9090  ALL                                                                                             PassthroughCluster
10.200.1.10 9153  Trans: raw_buffer; App: http/1.1,h2c                                                            Route: kube-dns.kube-system.svc.cluster.local:9153
10.200.1.10 9153  ALL                                                                                             Cluster: outbound|9153||kube-dns.kube-system.svc.cluster.local
0.0.0.0     9411  Trans: raw_buffer; App: http/1.1,h2c                                                            Route: 9411
0.0.0.0     9411  ALL                                                                                             PassthroughCluster
10.200.1.26 14250 Trans: raw_buffer; App: http/1.1,h2c                                                            Route: jaeger-collector.istio-system.svc.cluster.local:14250
10.200.1.26 14250 ALL                                                                                             Cluster: outbound|14250||jaeger-collector.istio-system.svc.cluster.local
10.200.1.26 14268 Trans: raw_buffer; App: http/1.1,h2c                                                            Route: jaeger-collector.istio-system.svc.cluster.local:14268
10.200.1.26 14268 ALL                                                                                             Cluster: outbound|14268||jaeger-collector.istio-system.svc.cluster.local
0.0.0.0     15001 ALL                                                                                             PassthroughCluster
0.0.0.0     15001 Addr: *:15001                                                                                   Non-HTTP/Non-TCP
0.0.0.0     15006 Addr: *:15006                                                                                   Non-HTTP/Non-TCP
0.0.0.0     15006 Trans: tls; App: istio-http/1.0,istio-http/1.1,istio-h2; Addr: 0.0.0.0/0                        InboundPassthroughClusterIpv4
0.0.0.0     15006 Trans: raw_buffer; App: http/1.1,h2c; Addr: 0.0.0.0/0                                           InboundPassthroughClusterIpv4
0.0.0.0     15006 Trans: tls; App: TCP TLS; Addr: 0.0.0.0/0                                                       InboundPassthroughClusterIpv4
0.0.0.0     15006 Trans: raw_buffer; Addr: 0.0.0.0/0                                                              InboundPassthroughClusterIpv4
0.0.0.0     15006 Trans: tls; Addr: 0.0.0.0/0                                                                     InboundPassthroughClusterIpv4
0.0.0.0     15006 Trans: tls; App: istio,istio-peer-exchange,istio-http/1.0,istio-http/1.1,istio-h2; Addr: *:8080 Cluster: inbound|8080||
0.0.0.0     15006 Trans: raw_buffer; Addr: *:8080                                                                 Cluster: inbound|8080||
0.0.0.0     15010 Trans: raw_buffer; App: http/1.1,h2c                                                            Route: 15010
0.0.0.0     15010 ALL                                                                                             PassthroughCluster
10.200.1.45 15012 ALL                                                                                             Cluster: outbound|15012||istiod.istio-system.svc.cluster.local
0.0.0.0     15014 Trans: raw_buffer; App: http/1.1,h2c                                                            Route: 15014
0.0.0.0     15014 ALL                                                                                             PassthroughCluster
0.0.0.0     15021 ALL                                                                                             Inline Route: /healthz/ready*
10.200.1.29 15021 Trans: raw_buffer; App: http/1.1,h2c                                                            Route: istio-ingressgateway.istio-system.svc.cluster.local:15021
10.200.1.29 15021 ALL                                                                                             Cluster: outbound|15021||istio-ingressgateway.istio-system.svc.cluster.local
0.0.0.0     15090 ALL                                                                                             Inline Route: /stats/prometheus*
0.0.0.0     16685 Trans: raw_buffer; App: http/1.1,h2c                                                            Route: 16685
0.0.0.0     16685 ALL                                                                                             PassthroughCluster
0.0.0.0     20001 Trans: raw_buffer; App: http/1.1,h2c                                                            Route: 20001
0.0.0.0     20001 ALL                                                                                             PassthroughCluster

NAME                                                          DOMAINS                                            MATCH                  VIRTUAL SERVICE
80                                                            catalog, catalog.istioinaction + 1 more...         /*
80                                                            istio-ingressgateway.istio-system, 10.200.1.29     /*
80                                                            tracing.istio-system, 10.200.1.107                 /*
80                                                            webapp, webapp.istioinaction + 1 more...           /*
istio-ingressgateway.istio-system.svc.cluster.local:15021     *                                                  /*
9411                                                          jaeger-collector.istio-system, 10.200.1.26         /*
9411                                                          zipkin.istio-system, 10.200.1.232                  /*
20001                                                         kiali.istio-system, 10.200.1.141                   /*
jaeger-collector.istio-system.svc.cluster.local:14250         *                                                  /*
9090                                                          kiali.istio-system, 10.200.1.141                   /*
9090                                                          prometheus.istio-system, 10.200.1.37               /*
grafana.istio-system.svc.cluster.local:3000                   *                                                  /*
jaeger-collector.istio-system.svc.cluster.local:14268         *                                                  /*
inbound|8080||                                                *                                                  /*
15010                                                         istiod.istio-system, 10.200.1.45                   /*
kube-dns.kube-system.svc.cluster.local:9153                   *                                                  /*
15014                                                         istiod.istio-system, 10.200.1.45                   /*
InboundPassthroughClusterIpv4                                 *                                                  /*
                                                              *                                                  /stats/prometheus*
inbound|8080||                                                *                                                  /*
                                                              *                                                  /healthz/ready*
InboundPassthroughClusterIpv4                                 *                                                  /*
16685                                                         tracing.istio-system, 10.200.1.107                 /*

RESOURCE NAME     TYPE           STATUS     VALID CERT     SERIAL NUMBER                               NOT AFTER                NOT BEFORE
default           Cert Chain     ACTIVE     true           163902049231284172313509795334792256015     2025-04-13T09:38:28Z     2025-04-12T09:36:28Z
ROOTCA            CA             ACTIVE     true           288766384546012559812257962513943000525     2035-04-10T09:20:31Z     2025-04-12T09:20:31Z

💠 kind 클러스터에서 Istio의 istio-ingressgateway 파드의 네트워크 리스너(트래픽을 받는 포트) 설정

  • 8080 포트: 외부에서 오는 웹 요청(예: webapp으로 가는 요청)을 받아서 처리
  • 15021 포트: Istio가 건강한지 확인
  • 15090 포트: Istio의 성능 데이터를 모니터링 도구에 보내는 문
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ docker exec -it myk8s-control-plane istioctl proxy-config listener $ISTIOIGW
ADDRESS PORT  MATCH DESTINATION
0.0.0.0 8080  ALL   Route: http.8080
0.0.0.0 15021 ALL   Inline Route: /healthz/ready*
0.0.0.0 15090 ALL   Inline Route: /stats/prometheus*

💠 Ingress Gateway가 외부에서 들어오는 HTTP 요청(포트 8080) 설정

  • 모든 도메인에서 들어오는 요청을 받아들임.
  • 요청 경로가 /로 시작하거나, /healthz/ready, /stats/prometheus로 시작하는 경우, 이 요청들은 webapp-virtualservice 설정에 따라 처리됨.
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ docker exec -it myk8s-control-plane istioctl proxy-config route $ISTIOIGW
NAME          DOMAINS     MATCH                  VIRTUAL SERVICE
http.8080     *           /*                     webapp-virtualservice.istioinaction
              *           /healthz/ready*
              *           /stats/prometheus*

💠 ingress Gateway가 연결할 수 있는 서비스(클러스터) 목록

  • Ingress Gateway는 외부에서 들어오는 요청을 받아서 내부 서비스(예: webapp, catalog)로 보낼 수 있어요.
  • 또한, 모니터링 도구(예: prometheusjaegerkiali)나 Istio 자체 관리 서비스(istiod)와도 통신할 수 있도록 설정되어 있습니다.
  • BlackHoleClusterxds-grpc 같은 가상 서비스는 Istio가 내부적으로 사용하는 설정이에요.
  • 모든 서비스는 주로 EDS 방식으로 동적으로 주소를 찾아서 연결되고, 포트(예: 80, 443 등)를 통해 통신합니다.
  •  
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ docker exec -it myk8s-control-plane istioctl proxy-config cluster $ISTIOIGW
SERVICE FQDN                                            PORT      SUBSET     DIRECTION     TYPE           DESTINATION RULE
BlackHoleCluster                                        -         -          -             STATIC       
agent                                                   -         -          -             STATIC       
catalog.istioinaction.svc.cluster.local                 80        -          outbound      EDS          
grafana.istio-system.svc.cluster.local                  3000      -          outbound      EDS          
istio-ingressgateway.istio-system.svc.cluster.local     80        -          outbound      EDS          
istio-ingressgateway.istio-system.svc.cluster.local     443       -          outbound      EDS          
istio-ingressgateway.istio-system.svc.cluster.local     15021     -          outbound      EDS          
istiod.istio-system.svc.cluster.local                   443       -          outbound      EDS          
istiod.istio-system.svc.cluster.local                   15010     -          outbound      EDS          
istiod.istio-system.svc.cluster.local                   15012     -          outbound      EDS          
istiod.istio-system.svc.cluster.local                   15014     -          outbound      EDS          
jaeger-collector.istio-system.svc.cluster.local         9411      -          outbound      EDS          
jaeger-collector.istio-system.svc.cluster.local         14250     -          outbound      EDS          
jaeger-collector.istio-system.svc.cluster.local         14268     -          outbound      EDS          
kiali.istio-system.svc.cluster.local                    9090      -          outbound      EDS          
kiali.istio-system.svc.cluster.local                    20001     -          outbound      EDS          
kube-dns.kube-system.svc.cluster.local                  53        -          outbound      EDS          
kube-dns.kube-system.svc.cluster.local                  9153      -          outbound      EDS          
kubernetes.default.svc.cluster.local                    443       -          outbound      EDS          
prometheus.istio-system.svc.cluster.local               9090      -          outbound      EDS          
prometheus_stats                                        -         -          -             STATIC       
sds-grpc                                                -         -          -             STATIC       
tracing.istio-system.svc.cluster.local                  80        -          outbound      EDS          
tracing.istio-system.svc.cluster.local                  16685     -          outbound      EDS          
webapp.istioinaction.svc.cluster.local                  80        -          outbound      EDS          
xds-grpc                                                -         -          -             STATIC       
zipkin                                                  -         -          -             STRICT_DNS   
zipkin.istio-system.svc.cluster.local                   9411      -          outbound      EDS

💠 ingress Gateway가 연결할 수 있는 엔드포인트 목록

  • Ingress Gateway는 webappcatalog 같은 애플리케이션 서비스뿐만 아니라 prometheusjaegerkiali 같은 모니터링 도구, 그리고 istiod 같은 Istio 관리 서비스와 연결할 수 있어요.
  • 각 서비스는 특정 IP와 포트(예: 10.10.0.12:8080)로 연결되며, 모두 HEALTHY 상태라 문제없이 작동하고 있습니다.
  • kube-dnszipkinxds-grpc 같은 엔드포인트는 쿠버네티스와 Istio가 시스템을 관리하는 데 필요한 내부 서비스예요.
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ docker exec -it myk8s-control-plane istioctl proxy-config endpoint $ISTIOIGW
ENDPOINT                                                STATUS      OUTLIER CHECK     CLUSTER
10.10.0.10:9090                                         HEALTHY     OK                outbound|9090||prometheus.istio-system.svc.cluster.local
10.10.0.11:3000                                         HEALTHY     OK                outbound|80||catalog.istioinaction.svc.cluster.local
10.10.0.12:8080                                         HEALTHY     OK                outbound|80||webapp.istioinaction.svc.cluster.local
10.10.0.2:53                                            HEALTHY     OK                outbound|53||kube-dns.kube-system.svc.cluster.local
10.10.0.2:9153                                          HEALTHY     OK                outbound|9153||kube-dns.kube-system.svc.cluster.local
10.10.0.3:53                                            HEALTHY     OK                outbound|53||kube-dns.kube-system.svc.cluster.local
10.10.0.3:9153                                          HEALTHY     OK                outbound|9153||kube-dns.kube-system.svc.cluster.local
10.10.0.5:15010                                         HEALTHY     OK                outbound|15010||istiod.istio-system.svc.cluster.local
10.10.0.5:15012                                         HEALTHY     OK                outbound|15012||istiod.istio-system.svc.cluster.local
10.10.0.5:15014                                         HEALTHY     OK                outbound|15014||istiod.istio-system.svc.cluster.local
10.10.0.5:15017                                         HEALTHY     OK                outbound|443||istiod.istio-system.svc.cluster.local
10.10.0.6:8080                                          HEALTHY     OK                outbound|80||istio-ingressgateway.istio-system.svc.cluster.local
10.10.0.6:8443                                          HEALTHY     OK                outbound|443||istio-ingressgateway.istio-system.svc.cluster.local
10.10.0.6:15021                                         HEALTHY     OK                outbound|15021||istio-ingressgateway.istio-system.svc.cluster.local
10.10.0.7:3000                                          HEALTHY     OK                outbound|3000||grafana.istio-system.svc.cluster.local
10.10.0.8:9411                                          HEALTHY     OK                outbound|9411||jaeger-collector.istio-system.svc.cluster.local
10.10.0.8:9411                                          HEALTHY     OK                outbound|9411||zipkin.istio-system.svc.cluster.local
10.10.0.8:14250                                         HEALTHY     OK                outbound|14250||jaeger-collector.istio-system.svc.cluster.local
10.10.0.8:14268                                         HEALTHY     OK                outbound|14268||jaeger-collector.istio-system.svc.cluster.local
10.10.0.8:16685                                         HEALTHY     OK                outbound|16685||tracing.istio-system.svc.cluster.local
10.10.0.8:16686                                         HEALTHY     OK                outbound|80||tracing.istio-system.svc.cluster.local
10.10.0.9:9090                                          HEALTHY     OK                outbound|9090||kiali.istio-system.svc.cluster.local
10.10.0.9:20001                                         HEALTHY     OK                outbound|20001||kiali.istio-system.svc.cluster.local
10.200.1.232:9411                                       HEALTHY     OK                zipkin
127.0.0.1:15000                                         HEALTHY     OK                prometheus_stats
127.0.0.1:15020                                         HEALTHY     OK                agent
172.18.0.2:6443                                         HEALTHY     OK                outbound|443||kubernetes.default.svc.cluster.local
unix://./etc/istio/proxy/XDS                            HEALTHY     OK                xds-grpc
unix://./var/run/secrets/workload-spiffe-uds/socket     HEALTHY     OK                sds-grpc

💠 Ingress Gateway의 로그 카테고리와 각 카테고리의 로그 레벨

  • Ingress Gateway는 HTTP 요청, 라우팅, 추적, 관리 작업 등 다양한 활동(카테고리)을 로그로 기록합니다.
  • 대부분의 로그는 warning 레벨로 설정되어 있어서, 오류나 주의해야 할 상황만 기록됩니다. 
  • misc 카테고리만 error 레벨이라, 잡다한 로그는 정말 심각한 문제만 기록합니다.
  • 이 설정은 시스템이 정상적으로 작동할 때 적당한 양의 로그를 남기면서, 문제가 생기면 필요한 정보를 확인할 수 있게 해줍니다.
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ docker exec -it myk8s-control-plane istioctl proxy-config log $ISTIOIGW
istio-ingressgateway-996bc6bb6-vgg65.istio-system:
active loggers:
  admin: warning
  alternate_protocols_cache: warning
  aws: warning
  assert: warning
  backtrace: warning
  cache_filter: warning
  client: warning
  config: warning
  connection: warning
  conn_handler: warning
  decompression: warning
  dns: warning
  dubbo: warning
  envoy_bug: warning
  ext_authz: warning
  ext_proc: warning
  rocketmq: warning
  file: warning
  filter: warning
  forward_proxy: warning
  grpc: warning
  happy_eyeballs: warning
  hc: warning
  health_checker: warning
  http: warning
  http2: warning
  hystrix: warning
  init: warning
  io: warning
  jwt: warning
  kafka: warning
  key_value_store: warning
  lua: warning
  main: warning
  matcher: warning
  misc: error
  mongo: warning
  multi_connection: warning
  oauth2: warning
  quic: warning
  quic_stream: warning
  pool: warning
  rate_limit_quota: warning
  rbac: warning
  rds: warning
  redis: warning
  router: warning
  runtime: warning
  stats: warning
  secret: warning
  tap: warning
  testing: warning
  thrift: warning
  tracing: warning
  upstream: warning
  udp: warning
  wasm: warning
  websocket: warning

💠 Ingress Gateway 가 사용하는 보안 인증서(secret) 정보

  • Ingress Gateway는 두 개의 인증서를 사용하고 있어요:
    • default (Cert Chain): 실제로 외부 요청(예: HTTPS)을 처리할 때 사용하는 인증서. 유효 기간은 2025년 4월 12일부터 13일까지(1일).
    • ROOTCA (CA): default 인증서를 발급한 인증 기관의 인증서. 유효 기간은 2025년 4월 12일부터 2035년 4월 10일까지(10년).
  • 두 인증서 모두 ACTIVE이고 VALID CERT 상태라 정상적으로 작동하고 있습니다.
  • 이 인증서들은 Ingress Gateway가 외부와 안전하게 통신(예: HTTPS 웹사이트 제공)하거나 내부 서비스와 신뢰를 확인할 때 사용됩니다.
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ docker exec -it myk8s-control-plane istioctl proxy-config secret $ISTIOIGW
RESOURCE NAME     TYPE           STATUS     VALID CERT     SERIAL NUMBER                               NOT AFTER                NOT BEFORE
default           Cert Chain     ACTIVE     true           77748410043224152587897040189531781500      2025-04-13T09:20:41Z     2025-04-12T09:18:41Z
ROOTCA            CA             ACTIVE     true           288766384546012559812257962513943000525     2035-04-10T09:20:31Z     2025-04-12T09:20:31Z

💠 istio-ingressgateway 서비스 NodePort 변경 및 nodeport 30000로 지정 변경

(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ kubectl get svc,ep -n istio-system istio-ingressgateway
NAME                           TYPE           CLUSTER-IP    EXTERNAL-IP   PORT(S)                                      AGE
service/istio-ingressgateway   LoadBalancer   10.200.1.29   <pending>     15021:30873/TCP,80:32037/TCP,443:32477/TCP   92m

NAME                             ENDPOINTS                                       AGE
endpoints/istio-ingressgateway   10.10.0.6:15021,10.10.0.6:8080,10.10.0.6:8443   92m
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ kubectl patch svc -n istio-system istio-ingressgateway -p '{"spec": {"type": "NodePort", "ports": [{"port": 80, "targetPort": 8080, "nodePort": 30000}]}}'
service/istio-ingressgateway patched
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ kubectl get svc -n istio-system istio-ingressgateway
NAME                   TYPE       CLUSTER-IP    EXTERNAL-IP   PORT(S)                                      AGE
istio-ingressgateway   NodePort   10.200.1.29   <none>        15021:30873/TCP,80:30000/TCP,443:32477/TCP   92m

💠 istio-ingressgateway 서비스 externalTrafficPolicy 설정 : ClientIP 수집 확인

(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ kubectl patch svc -n istio-system istio-ingressgateway -p '{"spec":{"externalTrafficPolicy": "Local"}}'
service/istio-ingressgateway patched
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ kubectl describe svc -n istio-system istio-ingressgateway
Name:                     istio-ingressgateway
Namespace:                istio-system
Labels:                   app=istio-ingressgateway
                          install.operator.istio.io/owning-resource=unknown
                          install.operator.istio.io/owning-resource-namespace=istio-system
                          istio=ingressgateway
                          istio.io/rev=default
                          operator.istio.io/component=IngressGateways
                          operator.istio.io/managed=Reconcile
                          operator.istio.io/version=1.17.8
                          release=istio
Annotations:              <none>
Selector:                 app=istio-ingressgateway,istio=ingressgateway
Type:                     NodePort
IP Family Policy:         SingleStack
IP Families:              IPv4
IP:                       10.200.1.29
IPs:                      10.200.1.29
Port:                     status-port  15021/TCP
TargetPort:               15021/TCP
NodePort:                 status-port  30873/TCP
Endpoints:                10.10.0.6:15021
Port:                     http2  80/TCP
TargetPort:               8080/TCP
NodePort:                 http2  30000/TCP
Endpoints:                10.10.0.6:8080
Port:                     https  443/TCP
TargetPort:               8443/TCP
NodePort:                 https  32477/TCP
Endpoints:                10.10.0.6:8443
Session Affinity:         None
External Traffic Policy:  Local
Internal Traffic Policy:  Cluster
Events:
  Type    Reason  Age    From                Message
  ----    ------  ----   ----                -------
  Normal  Type    5m18s  service-controller  LoadBalancer -> NodePort

💠 모든 요청은 127.0.0.1:30000을 통해 Istio Ingress Gateway로 들어가서 catalog 서비스로 전달

  • curl -s http://127.0.0.1:30000/api/catalog | jq
    전체 상품 목록을 요청해서 JSON 형식으로 보기 좋게 출력.
  • curl -s http://127.0.0.1:30000/api/catalog/items/1 | jq
    ID가 1인 특정 상품의 정보를 요청해서 JSON으로 출력.
  • curl -s http://127.0.0.1:30000/api/catalog -I | head -n 1
    상품 목록 요청의 HTTP 상태 코드(응답 결과)만 확인.
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ curl -s http://127.0.0.1:30000/api/catalog | jq
[
  {
    "id": 1,
    "color": "amber",
    "department": "Eyewear",
    "name": "Elinor Glasses",
    "price": "282.00"
  },
  {
    "id": 2,
    "color": "cyan",
    "department": "Clothing",
    "name": "Atlas Shirt",
    "price": "127.00"
  },
  {
    "id": 3,
    "color": "teal",
    "department": "Clothing",
    "name": "Small Metal Shoes",
    "price": "232.00"
  },
  {
    "id": 4,
    "color": "red",
    "department": "Watches",
    "name": "Red Dragon Watch",
    "price": "232.00"
  }
]
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ curl -s http://127.0.0.1:30000/api/catalog/items/1 | jq
{
  "id": 1,
  "color": "amber",
  "department": "Eyewear",
  "name": "Elinor Glasses",
  "price": "282.00"
}
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ curl -s http://127.0.0.1:30000/api/catalog -I | head -n 1
HTTP/1.1 200 OK

💠 NodePort 변경 및 nodeport 30001~30003으로 변경 : prometheus(30001), grafana(30002), kiali(30003), tracing(30004)

(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ kubectl patch svc -n istio-system prometheus -p '{"spec": {"type": "NodePort", "ports": [{"port": 9090, "targetPort": 9090, "nodePort": 30001}]}}'
service/prometheus patched
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ kubectl patch svc -n istio-system grafana -p '{"spec": {"type": "NodePort", "ports": [{"port": 3000, "targetPort": 3000, "nodePort": 30002}]}}'
service/grafana patched
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ kubectl patch svc -n istio-system kiali -p '{"spec": {"type": "NodePort", "ports": [{"port": 20001, "targetPort": 20001, "nodePort": 30003}]}}'
service/kiali patched
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ kubectl patch svc -n istio-system tracing -p '{"spec": {"type": "NodePort", "ports": [{"port": 80, "targetPort": 16686, "nodePort": 30004}]}}'
service/tracing patched

💠 Grafana 대시보드 - Istio Service Dashboard ⇒ 상단 Service (webapp.. 선택)

💠 Jaeger 트레이싱 대시보드 => 가장 최근의 호출 목록과 그 호출의 분산 트레이싱 스팬 확인 가능.

  • Istio의 역할: Istio는 서비스 프록시를 통해 서비스 간 트레이싱 ID와 메타데이터를 전파하고, 트레이싱 엔진(Zipkin, Jaeger)에 트레이싱 스팬 정보를 보냅니다. 애플리케이션의 개입은 거의 필요 없습니다.
  • 애플리케이션의 역할: 애플리케이션은 내부에서 들어오는 요청의 트레이싱 메타데이터(주로 HTTP 헤더)를 받아 나가는 요청에 연결해야 합니다. 즉, 요청 간 인과 관계를 유지하려면 애플리케이션이 헤더를 적절히 전파해야 합니다.
  • Istio는 서비스 간 트레이싱을 관리하고 트레이싱 엔진으로 데이터를 보내지만, 애플리케이션 내부의 트레이싱 메타데이터 전파와 인과 관계 유지는 애플리케이션의 책임입니다.

💠 Kiali : 메트릭(프로메테우스)과 트레이싱(zipkin, jaeger, tempo)을 수집하여 해당 정보를 기반으로 시각화!

Comments