Kubernetes Tools/Istio

[Istio ๊ฐ€์ด๋“œ ep.25] 4๋ถ€ ๋ชจ๋‹ˆํ„ฐ๋ง #1 | Prometheus & Grafana๋กœ Istio ๋ฉ”ํŠธ๋ฆญ ์ˆ˜์ง‘ ๋ฐ ๋ชจ๋‹ˆํ„ฐ๋ง ๊ตฌ์ถ•

ygtoken 2025. 3. 18. 12:09
728x90

๐Ÿ”น ๊ฐœ์š”

์ด๋ฒˆ ๊ธ€์—์„œ๋Š” Istio์—์„œ Prometheus์™€ Grafana๋ฅผ ํ™œ์šฉํ•˜์—ฌ ์„œ๋น„์Šค ๋ฉ”ํŠธ๋ฆญ์„ ์ˆ˜์ง‘ํ•˜๊ณ  ๋ชจ๋‹ˆํ„ฐ๋ง์„ ๊ตฌ์ถ•ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.
Istio๋Š” Envoy ํ”„๋ก์‹œ๋ฅผ ํ†ตํ•ด ์„œ๋น„์Šค ํŠธ๋ž˜ํ”ฝ ๋ฐ์ดํ„ฐ๋ฅผ ์ˆ˜์ง‘ํ•˜๋ฉฐ,
์ด๋ฅผ Prometheus๋ฅผ ํ†ตํ•ด ์ €์žฅํ•˜๊ณ , Grafana๋ฅผ ํ™œ์šฉํ•˜์—ฌ ์‹œ๊ฐํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด ๊ธ€์—์„œ๋Š” Prometheus ๋ฐ Grafana์˜ ๊ฐœ๋…, Istio์—์„œ ๋ฉ”ํŠธ๋ฆญ์„ ์ˆ˜์ง‘ํ•˜๋Š” ๋ฐฉ๋ฒ•, ๋ชจ๋‹ˆํ„ฐ๋ง ๋Œ€์‹œ๋ณด๋“œ ๊ตฌ์„ฑ ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.


๐Ÿ”น 1. Istio์—์„œ Prometheus & Grafana๊ฐ€ ํ•„์š”ํ•œ ์ด์œ 

โœ… 1.1 Prometheus๋ž€?

Prometheus๋Š” ์˜คํ”ˆ์†Œ์Šค ๋ชจ๋‹ˆํ„ฐ๋ง ๋ฐ ์•Œ๋ฆผ ์‹œ์Šคํ…œ์œผ๋กœ,
์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋ฐ ์„œ๋น„์Šค์—์„œ ์‹ค์‹œ๊ฐ„ ๋ฉ”ํŠธ๋ฆญ ๋ฐ์ดํ„ฐ๋ฅผ ์ˆ˜์ง‘ํ•˜๊ณ  ์ €์žฅํ•˜๋Š” ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค.

Prometheus์˜ ์ฃผ์š” ๊ธฐ๋Šฅ

  • ์‹œ๊ณ„์—ด(Time-Series) ๊ธฐ๋ฐ˜ ๋ฐ์ดํ„ฐ ์ €์žฅ ๋ฐ ๋ถ„์„
  • HTTP ๊ธฐ๋ฐ˜์˜ ๊ฐ•๋ ฅํ•œ ์ฟผ๋ฆฌ ์–ธ์–ด(PromQL) ์ œ๊ณต
  • ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋ฐ ์ธํ”„๋ผ ๋ฉ”ํŠธ๋ฆญ์„ ์‹ค์‹œ๊ฐ„ ๋ชจ๋‹ˆํ„ฐ๋ง
  • ์•Œ๋ฆผ ์‹œ์Šคํ…œ(Alertmanager)๊ณผ ์—ฐ๋™ ๊ฐ€๋Šฅ

โœ… 1.2 Grafana๋ž€?

Grafana๋Š” Prometheus ๋“ฑ์˜ ๋ชจ๋‹ˆํ„ฐ๋ง ๋ฐ์ดํ„ฐ๋ฅผ ์‹œ๊ฐํ™”ํ•˜๋Š” ๋Œ€์‹œ๋ณด๋“œ ํˆด์ž…๋‹ˆ๋‹ค.

Grafana์˜ ์ฃผ์š” ๊ธฐ๋Šฅ

  • Prometheus์™€ ์—ฐ๋™ํ•˜์—ฌ ์‹ค์‹œ๊ฐ„ ๋ฐ์ดํ„ฐ ์‹œ๊ฐํ™”
  • ๋Œ€์‹œ๋ณด๋“œ๋ฅผ ํ™œ์šฉํ•˜์—ฌ ์„œ๋น„์Šค ์ƒํƒœ ๋ชจ๋‹ˆํ„ฐ๋ง ๊ฐ€๋Šฅ
  • Istio ๋ฉ”ํŠธ๋ฆญ(ํŠธ๋ž˜ํ”ฝ, ์˜ค๋ฅ˜์œจ, ์ง€์—ฐ ์‹œ๊ฐ„ ๋“ฑ)์„ ๋ถ„์„ํ•˜๋Š” ๋ฐ ์ตœ์ ํ™”

๐Ÿ’ก Istio์—์„œ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ Prometheus์™€ Grafana๋ฅผ ์ง€์›ํ•˜๋ฉฐ, ์ด๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๋„คํŠธ์›Œํฌ ํŠธ๋ž˜ํ”ฝ ๋ฐ ์„œ๋น„์Šค ์ƒํƒœ๋ฅผ ๋ชจ๋‹ˆํ„ฐ๋งํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


๐Ÿ”น 2. Istio์—์„œ Prometheus ์„ค์น˜ ๋ฐ ์„ค์ •

โœ… 2.1 Istio์™€ ํ•จ๊ป˜ Prometheus ์„ค์น˜ํ•˜๊ธฐ

Istio์—๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ Prometheus๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ์œผ๋ฉฐ, Helm Chart๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

helm repo add istio https://istio-release.storage.googleapis.com/charts
helm repo update

helm install istio-base istio/base -n istio-system --create-namespace
helm install istiod istio/istiod -n istio-system
helm install istio-prometheus istio/prometheus -n istio-system

๐Ÿ’ก istio/prometheus Helm Chart๋ฅผ ์„ค์น˜ํ•˜๋ฉด Istio์˜ ๋ฉ”ํŠธ๋ฆญ์„ ์ž๋™์œผ๋กœ ์ˆ˜์ง‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


โœ… 2.2 Prometheus ์„œ๋น„์Šค ํ™•์ธ

์„ค์น˜๊ฐ€ ์™„๋ฃŒ๋˜๋ฉด Prometheus๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์‹คํ–‰๋˜๊ณ  ์žˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

kubectl get pods -n istio-system | grep prometheus

 

์ถœ๋ ฅ ์˜ˆ์ œ:

istio-prometheus-5c6d87f7bb-8p7z7   1/1   Running   0     10m

โœ… 2.3 Prometheus ์›น UI ์ ‘์†

Prometheus์˜ ์›น UI์— ์ ‘์†ํ•˜๋ ค๋ฉด ํฌํŠธ๋ฅผ ํฌ์›Œ๋”ฉํ•ฉ๋‹ˆ๋‹ค.

kubectl port-forward -n istio-system svc/istio-prometheus 9090:9090

์›น ๋ธŒ๋ผ์šฐ์ €์—์„œ http://localhost:9090 ์— ์ ‘์†ํ•˜๋ฉด Prometheus UI๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ’ก PromQL์„ ํ™œ์šฉํ•˜์—ฌ Istio ๋ฉ”ํŠธ๋ฆญ์„ ์ง์ ‘ ์กฐํšŒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


๐Ÿ”น 3. Istio์—์„œ Grafana ์„ค์น˜ ๋ฐ ๋Œ€์‹œ๋ณด๋“œ ๊ตฌ์„ฑ

โœ… 3.1 Istio์™€ ํ•จ๊ป˜ Grafana ์„ค์น˜ํ•˜๊ธฐ

Istio๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ Grafana ๋Œ€์‹œ๋ณด๋“œ๋ฅผ ํฌํ•จํ•˜๊ณ  ์žˆ์œผ๋ฉฐ, Helm Chart๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

helm install istio-grafana istio/grafana -n istio-system

โœ… 3.2 Grafana ์„œ๋น„์Šค ํ™•์ธ ๋ฐ ์ ‘์†

Grafana๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์‹คํ–‰๋˜๊ณ  ์žˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

kubectl get pods -n istio-system | grep grafana

 

์ถœ๋ ฅ ์˜ˆ์ œ:

istio-grafana-6b798fbdc8-txz8m   1/1   Running   0     5m

 

Grafana UI์— ์ ‘์†ํ•˜๋ ค๋ฉด ํฌํŠธ๋ฅผ ํฌ์›Œ๋”ฉํ•ฉ๋‹ˆ๋‹ค.

kubectl port-forward -n istio-system svc/istio-grafana 3000:3000

์›น ๋ธŒ๋ผ์šฐ์ €์—์„œ http://localhost:3000 ์— ์ ‘์†ํ•˜๋ฉด Grafana UI๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


โœ… 3.3 Grafana์—์„œ Istio ๋Œ€์‹œ๋ณด๋“œ ํ™•์ธ

Grafana์—์„œ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ œ๊ณตํ•˜๋Š” Istio ๋Œ€์‹œ๋ณด๋“œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

1๏ธโƒฃ Istio Mesh Dashboard → Istio ์„œ๋น„์Šค ์ „์ฒด ์ƒํƒœ ๋ชจ๋‹ˆํ„ฐ๋ง
2๏ธโƒฃ Istio Service Dashboard → ํŠน์ • ์„œ๋น„์Šค์˜ ํŠธ๋ž˜ํ”ฝ, ์˜ค๋ฅ˜์œจ, ์‘๋‹ต ์‹œ๊ฐ„ ํ™•์ธ
3๏ธโƒฃ Istio Workload Dashboard → ํŠน์ • ์›Œํฌ๋กœ๋“œ(Pod) ์ˆ˜์ค€์˜ ์„ฑ๋Šฅ ๋ชจ๋‹ˆํ„ฐ๋ง
4๏ธโƒฃ Istio Control Plane Dashboard → Istio์˜ ์ปจํŠธ๋กค ํ”Œ๋ ˆ์ธ ์„ฑ๋Šฅ ๋ถ„์„

๐Ÿ’ก Grafana์˜ ๊ธฐ๋ณธ Istio ๋Œ€์‹œ๋ณด๋“œ๋ฅผ ํ™œ์šฉํ•˜๋ฉด, ์„œ๋น„์Šค์˜ ํŠธ๋ž˜ํ”ฝ ๋ฐ ์„ฑ๋Šฅ ์ƒํƒœ๋ฅผ ์‰ฝ๊ฒŒ ๋ชจ๋‹ˆํ„ฐ๋งํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


๐Ÿ”น 4. Prometheus & Grafana๋ฅผ ํ™œ์šฉํ•œ Istio ๋ฉ”ํŠธ๋ฆญ ๋ถ„์„

โœ… 4.1 ์ฃผ์š” Prometheus ๋ฉ”ํŠธ๋ฆญ ์กฐํšŒ

Prometheus์—์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ Istio ๊ด€๋ จ ๋ฉ”ํŠธ๋ฆญ์„ ์กฐํšŒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๋ฉ”ํŠธ๋ฆญ ์„ค๋ช…
istio_requests_total ์„œ๋น„์Šค ๊ฐ„ ์š”์ฒญ ์ด ๊ฐœ์ˆ˜
istio_request_duration_milliseconds ์š”์ฒญ ์ฒ˜๋ฆฌ ์‹œ๊ฐ„(์ง€์—ฐ ์‹œ๊ฐ„)
istio_tcp_sent_bytes_total TCP ํŠธ๋ž˜ํ”ฝ ์ „์†ก๋Ÿ‰
istio_tcp_received_bytes_total TCP ํŠธ๋ž˜ํ”ฝ ์ˆ˜์‹ ๋Ÿ‰

Prometheus์—์„œ ํŠน์ • ์„œ๋น„์Šค์˜ ์š”์ฒญ ์ˆ˜๋ฅผ ํ™•์ธํ•˜๋Š” ์ฟผ๋ฆฌ ์˜ˆ์ œ:

istio_requests_total{destination_service="my-service.default.svc.cluster.local"}

๐Ÿ’ก ์ด ์ฟผ๋ฆฌ๋ฅผ ์‹คํ–‰ํ•˜๋ฉด my-service ์„œ๋น„์Šค๋กœ ๋“ค์–ด์˜จ ์š”์ฒญ ์ˆ˜๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


โœ… 4.2 Grafana์—์„œ Istio ํŠธ๋ž˜ํ”ฝ ๋ชจ๋‹ˆํ„ฐ๋ง

Grafana์˜ Istio Service Dashboard์—์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฐ์ดํ„ฐ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • ์„œ๋น„์Šค ๋ณ„ ์š”์ฒญ ์ˆ˜, ์‘๋‹ต ์†๋„ ๋ฐ ์˜ค๋ฅ˜์œจ
  • HTTP ๋ฐ TCP ํŠธ๋ž˜ํ”ฝ๋Ÿ‰
  • ์„œ๋น„์Šค ๊ฐ„ ํŠธ๋ž˜ํ”ฝ ํ๋ฆ„ ๋ฐ ์„ฑ๋Šฅ

๐Ÿ“Œ ๊ฒฐ๋ก 

  • Istio์—์„œ Prometheus๋ฅผ ํ™œ์šฉํ•˜์—ฌ ์‹ค์‹œ๊ฐ„ ์„œ๋น„์Šค ๋ฉ”ํŠธ๋ฆญ์„ ์ˆ˜์ง‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • Grafana๋ฅผ ํ™œ์šฉํ•˜๋ฉด Prometheus์—์„œ ์ˆ˜์ง‘ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ๋Œ€์‹œ๋ณด๋“œ๋กœ ์‹œ๊ฐํ™”ํ•˜์—ฌ ์‰ฝ๊ฒŒ ๋ชจ๋‹ˆํ„ฐ๋งํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • Istio์˜ ๊ธฐ๋ณธ ๋Œ€์‹œ๋ณด๋“œ(Istio Mesh, Service, Workload Dashboard)๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๋„คํŠธ์›Œํฌ ๋ฐ ์„œ๋น„์Šค ์„ฑ๋Šฅ์„ ๋ถ„์„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • Prometheus์˜ PromQL์„ ์‚ฌ์šฉํ•˜์—ฌ ํŠน์ • ์„œ๋น„์Šค์˜ ์š”์ฒญ ์ˆ˜, ์˜ค๋ฅ˜์œจ, ์‘๋‹ต ์†๋„ ๋“ฑ์„ ์ƒ์„ธํžˆ ๋ถ„์„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
728x90