| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 |
- ip
- jvm
- tcp
- Network
- java
- kubectl
- grafana
- EC2
- zookeeper
- MAC address
- CVAT
- Packet
- Operating System
- CSV
- JavaScript
- Terraform
- docker
- kubernetes
- aws s3
- Kafka
- airflow
- helm
- Spring
- AWS
- Python
- OS
- PostgreSQL
- log
- Vision
- kubeadm
- Today
- Total
JUST WRITE
[Azure] AKS에 Grafana 모니터링 구축하기 본문

AKS에 Grafana 모니터링 구축하기
저번 포스팅에서 Terraform을 이용해서 Azure에 AKS를 구축하였습니다.
[Terraform] Azure AKS 클러스터 한번에 구축하기
Terrafrom으로 AKS 클러스터 구축TL;DRAzure VM에서 Terraform을 사용해 AKS 클러스터 + ACR을 한 번에 프로비저닝 하는 방법을 정리CNI는 eBPF 기반 Cilium, 디스크는 비용/성능 모두 유리한 Ephemeral 선택Terraform i
developnote-blog.tistory.com
구축하고 운영하다 보니 쉽게 AKS를 모니터링할 수 없을까 고민되었습니다.
특히 네트워크 관련 문제는 kubectl logs로는 찾기가 힘들었습니다.
- AKS 내 서비스 간 연결 문제
- 특정 Pod에서 타임 아웃 에러 문제가 네트워크 문제일 때
- NetworkPolicy를 적용했는데 의도치 않게 트래픽이 막힐 때
이번 포스팅에서 Cilium의 Hubble과 Grafana을 통해 네트워크 트래픽을 시각화하려고 합니다.
TL;DR
- AKS에 ACNS를 활성화해 Hubble 기반 네트워크 관측성 확인
- Azure Managed Grafana를 Terraform으로 프로비저닝
- Grafana 대시보드에서 네트워크 대시보드(DNS, Packet loss, Pod flow 등) 확인
전체 아키텍처
[AKS Cluster]
Cilium CNI + ACNS 활성화
│
│ eBPF로 모든 네트워크 패킷 추적
▼
[Hubble Relay]
모든 노드의 네트워크 흐름을 수집/집계
│
│ Prometheus 메트릭 형식으로 노출
▼
[ama-metrics]
메트릭을 스크래핑해서 Azure Monitor로 전송
│
│ 메트릭 저장
▼
[Azure Monitor Workspace]
Prometheus 메트릭 저장소
│
│ 데이터 조회
▼
[Azure Managed Grafana]
대시보드 시각화 (DNS, Drops, Pod Flows 등)
위와 같은 아키텍처로 구성합니다.
대신 그전에 아래와 같은 사전환경이 구성되어야 합니다.
- Terraform으로 AKS가 구축된 상태
- network_data_plane = "cilium"으로 Cilium CNI 사용 중
- Azure CLI 및 kubectl 설치 완료
ACNS 활성화
AKS에 ACNS(Advanced Container Networking Services)를 활성화해야 합니다.
ACNS는 네트워크 관측성과 보안 기능을 묶은 번들입니다.

ACNS를 활성화하면 AKS가 자동으로 Hubble Proxy Pod를 클러스터에 배포합니다.
Hubble
그럼 Hubble이 뭘까요?
Cilium 프로젝트에서 만든 오픈소스 네트워크 관측성 도구입니다.
Hubble은 eBPF를 통해서 네트워크 데이터를 수집합니다.
eBPF는 Linux 커널 안에서 코드를 실행하는 기술입니다.
덕분에 애플리케이션을 수정하지 않고도 커널에 지나가는 모든 패킷을 수집할 수 있습니다.

kube-proxy는 유저공간과 커널을 오가며 iptables를 거쳐야 했습니다.
eBPF는 커널안에서 바로 처리하므로 오버헤드 없이 바로 트래픽을 관찰할 수 있습니다.
ACNS를 활성화하면 AKS 각 노드 Cilium agent에서 Hubble이 동작합니다.
Hubble Relay에서 모든 노드의 Hubble 인스턴스에서 데이터를 수집해 하나로 집계합니다.
Node 1 Node 2 Node 3
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Cilium Agent│ │ Cilium Agent│ │ Cilium Agent│
│ + Hubble │ │ + Hubble │ │ + Hubble │
└─────────────┘ └─────────────┘ └─────────────┘
│ │ │
└─────────────────────────┴─────────────────────┘
│
▼
[Hubble Relay]
클러스터 전체 트래픽을
한 곳에서 집계
Terraform으로 AKS를 구성한다는 가정하에
main.tf내 network_profile 블록에 advanced_networking을 추가합니다.
resource "azurerm_kubernetes_cluster" "aks" {
# ... 기존 설정 ...
network_profile {
network_plugin = "azure"
network_plugin_mode = "overlay"
network_data_plane = "cilium"
# ACNS 활성화 - Hubble 관측성 + 보안 기능
advanced_networking {
observability_enabled = true
security_enabled = true
}
}
}
| 옵션 | 설명 |
| observability_enabled | Hubble 기반 네트워크 흐름 관측성 활성화 |
| security_enabled | FQDN 필터링 등 L7 보안 정책 활성화 |
Resource Provider 등록
Terraform에서 Azure Monitor와 Grafana를 생성하기 위해서 사전작업이 필요합니다.
해당 서비스의 Provider가 등록되어야 합니다.아래 Azure CLI 명령어로 등록할 수 있습니다.
az provider register --namespace Microsoft.Monitor
az provider register --namespace Microsoft.Dashboard
# 등록 확인 (Registered 상태까지 1~2분 소요)
az provider show --namespace Microsoft.Monitor --query registrationState
az provider show --namespace Microsoft.Dashboard --query registrationState
Azure Monitor, Grafana 생성
Terraform으로 Azure Monitor와 Grafana를 생성합니다.
단, AKS와 Azure Monitro 연동은 따로 Azure CLI로 설정합니다.
azurerm provider가 이 연동을 Terraform에서 직접 지원하지 않기 때문입니다.
main.tf에서 아래 리소스를 추가합니다.
# Azure Monitor Workspace (Prometheus 메트릭 저장소)
resource "azurerm_monitor_workspace" "monitor" {
name = var.monitor_name
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
}
# Azure Managed Grafana
resource "azurerm_dashboard_grafana" "grafana" {
name = var.grafana_name
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
grafana_major_version = 11
azure_monitor_workspace_integrations {
resource_id = azurerm_monitor_workspace.monitor.id
}
}
variables.tf에도 아래와 같이 추가합니다.
variable "monitor_name" {
default = "myAKSMonitor"
}
variable "grafana_name" {
description = "Grafana 인스턴스 이름 (전 세계 유니크)"
type = string
}
terraform.tfvars에도 아래와 같이 추가합니다.
monitor_name = "myAKSMonitor"
grafana_name = "myUniqueGrafanaName" # 전 세계 유니크한 이름으로 변경
이후 terraform apply 명령어도 Azure Monitor와 Grafana를 생성합니다.
Azure Monitror Metrics Addon 활성화
Terraform으로 Azure Monitor와 AKS를 연동합니다.
이 단계에서 ama-metrics Pod들이 클러스터에 배포됩니다.
aks-preview가 설치되어 있다면 --enable-azure-monitor-metrics 옵션과 충돌해,
Unsupported or missing identit type 에러가 발생합니다.
명령어 실행 전에 aks-preview를 삭제해야 합니다.
# aks-preview 확장 제거
az extension remove --name aks-preview
# Monitor, Grafana 리소스 ID를 변수에 저장
MONITOR_ID=$(az resource show \
--resource-group myRG \
--name ${AKSMonitor이름} \
--resource-type "Microsoft.Monitor/accounts" \
--query id --output tsv)
GRAFANA_ID=$(az grafana show \
--name ${Grafana이름} \
--resource-group ${리소스그룹이름} \
--query id --output tsv)
# AKS에 Azure Monitor Metrics Addon 활성화
az aks update \
--name myAKS \
--resource-group ${리소스그룹이름} \
--enable-azure-monitor-metrics \
--azure-monitor-workspace-resource-id $MONITOR_ID \
--grafana-resource-id $GRAFANA_ID
완료되면 아래 Pod들이 자동 배포됩니다.
| Pod | 역할 |
| ama-metrics | - 핵심 Metric 수집기 - Prometheus 형식으로 클러스터 Metric을 스크래핑해서 Azure Monitor로 전송 |
| ama-metrics-ksm | |
| ama-metrics-node | |
| ama-metrics-operator-targets | |
| ama-logs |
[참고자료]
Advanced Container Networking Services for Azure Kubernetes Service (AKS) Overview - Azure Kubernetes Service
Learn about Advanced Container Networking Services for Azure Kubernetes Service (AKS), including features like Container Network Observability and Container Network Security.
learn.microsoft.com
GitHub - cilium/hubble: Hubble - Network, Service & Security Observability for Kubernetes using eBPF
Hubble - Network, Service & Security Observability for Kubernetes using eBPF - cilium/hubble
github.com
Customize scraping of Prometheus metrics in Azure Monitor using ConfigMap - Azure Monitor
Customize metrics scraping for a Kubernetes cluster with the metrics add-on in Azure Monitor.
learn.microsoft.com
'Cloud' 카테고리의 다른 글
| [Terraform] Azure AKS 클러스터 한번에 구축하기 (0) | 2026.03.22 |
|---|---|
| [Terraform] AWS EKS 한 번에 올리기(1) - VPC 구성 (0) | 2024.11.03 |
| Client VPN 구성 - Private Subnet 외부에서 접근 (0) | 2024.02.27 |
| 빠르게 더 빠르게!!! - AWS Placement Group (0) | 2023.09.13 |
| credentials 설정 안해도 되네?! - AWS EC2 IAM 연결 (0) | 2023.08.03 |