Prometheus & Grafana 실행하기

Prometheus & Grafana 실행하기 (Running Prometheus & Grafana)

Cilium과 Hubble의 메트릭을 수집하고 시각화하기 위해 Prometheus와 Grafana를 함께 배포하는 예제 설정이에요. Grafana에는 Cilium Dashboard가 미리 로드되어 있어 바로 확인할 수 있습니다.

출처: Running Prometheus & Grafana

본문

Prometheus & Grafana 설치

이것은 Prometheus와 Grafana를 단일 배포에 포함하는 예제 배포예요.

Video

Cilium, Prometheus, Grafana가 함께 동작하는 모습은 KubeCon + CloudNativeCon 발표 Effortless Open Source Observability with Cilium, Prometheus and Grafana에서 확인할 수 있어요.

기본 설치에는 다음이 포함됩니다:

  • Grafana: Cilium Dashboard가 미리 로드된 시각화 대시보드.
  • Prometheus: 시계열 데이터베이스이자 모니터링 시스템.
$ kubectl apply -f https://raw.githubusercontent.com/cilium/cilium/1.20.2/examples/kubernetes/addons/prometheus/monitoring-example.yaml
namespace/cilium-monitoring created
serviceaccount/prometheus-k8s created
configmap/grafana-config created
configmap/grafana-cilium-dashboard created
configmap/grafana-cilium-operator-dashboard created
configmap/grafana-hubble-dashboard created
configmap/prometheus created
clusterrole.rbac.authorization.k8s.io/prometheus unchanged
clusterrolebinding.rbac.authorization.k8s.io/prometheus unchanged
service/grafana created
service/prometheus created
deployment.apps/grafana created
deployment.apps/prometheus created

이 Prometheus와 Grafana 예제 배포는 Cilium과 Hubble 메트릭을 자동으로 스크랩해요. 커스텀 Prometheus 인스턴스를 구성하는 방법은 모니터링 & 메트릭 구성 가이드를 참고하세요.

메트릭이 활성화된 Cilium과 Hubble 배포

Cilium, Hubble, Cilium Operator는 기본적으로 메트릭을 노출하지 않아요. 이 서비스들의 메트릭을 활성화하면 해당 컴포넌트가 실행 중인 클러스터의 모든 노드에서 각각 9962, 9965, 9963 포트가 열립니다.

Cilium, Hubble, Cilium Operator의 메트릭은 다음 Helm 값으로 서로 독립적으로 활성화할 수 있어요:

  • prometheus.enabled=true: cilium-agent의 메트릭을 활성화해요.
  • operator.prometheus.enabled=true: cilium-operator의 메트릭을 활성화해요.
  • hubble.metrics.enabled: 제공된 Hubble 메트릭 목록을 활성화해요. Hubble 메트릭이 동작하려면 Hubble 자체가 hubble.enabled=true로 활성화되어 있어야 해요. 사용 가능한 Hubble 메트릭 목록은 Hubble 내보내기 메트릭을 참고하세요.

개별 메트릭에 대한 자세한 내용은 모니터링 & 메트릭을 참고하세요.

Helm 저장소를 설정하세요:

Helm Repository

helm repo add cilium https://helm.cilium.io/

OCI Registry

Cilium 차트는 OCI 레지스트리(Quay.io 및 Docker Hub)에서도 제공돼요. 별도 설정 없이 oci:// URL로 바로 설치할 수 있습니다.

차트 서명 검증과 다이제스트 기반 설치를 포함한 자세한 내용은 OCI Registry 섹션을 참고하세요.

모든 메트릭을 활성화하려면 다음과 같이 Helm으로 Cilium을 배포하세요:

Helm Repository

helm install cilium cilium/cilium --version 1.20.2 \
   --namespace kube-system \
   --set prometheus.enabled=true \
   --set operator.prometheus.enabled=true \
   --set hubble.enabled=true \
   --set hubble.metrics.enableOpenMetrics=true \
   --set hubble.metrics.enabled="{dns,drop,tcp,flow,port-distribution,icmp,httpV2:exemplars=true;labelsContext=source_ip\,source_namespace\,source_workload\,destination_ip\,destination_namespace\,destination_workload\,traffic_direction}"

OCI Registry

helm install cilium oci://quay.io/cilium/charts/cilium 1.20.2 \
   --namespace kube-system \
   --set prometheus.enabled=true \
   --set operator.prometheus.enabled=true \
   --set hubble.enabled=true \
   --set hubble.metrics.enableOpenMetrics=true \
   --set hubble.metrics.enabled="{dns,drop,tcp,flow,port-distribution,icmp,httpV2:exemplars=true;labelsContext=source_ip\,source_namespace\,source_workload\,destination_ip\,destination_namespace\,destination_workload\,traffic_direction}"

Operator Prometheus TLS 구성

Operator Prometheus에서 TLS를 활성화하려면 먼저 tls.crt와 tls.key 키를 포함하는 secret을 만들어야 해요. 그런 다음 Helm 명령에 다음 플래그를 추가해 TLS를 활성화하세요:

--set operator.prometheus.tls.enabled=true                      # Enable TLS on Operator Prometheus
--set operator.prometheus.tls.server.existingSecret=secret-name # TLS secret name

mTLS도 활성화하려면 위 secret에 ca.crt 키를 추가하세요. 그리고 옵션 목록에 다음 Helm 플래그를 추가하면 됩니다:

--set operator.prometheus.tls.server.mtls.enabled=true # Use ca.crt of secret to verify client certificates

Note

위 Helm 옵션은 다른 설치 가이드들과 결합해서 사용할 수 있어요.

Grafana 접근 방법

로컬 머신에서 포트를 노출하세요.

kubectl -n cilium-monitoring port-forward service/grafana --address 0.0.0.0 --address :: 3000:3000

브라우저로 http://localhost:3000에 접근하세요.

Prometheus 접근 방법

로컬 머신에서 포트를 노출하세요.

kubectl -n cilium-monitoring port-forward service/prometheus --address 0.0.0.0 --address :: 9090:9090

브라우저로 http://localhost:9090에 접근하세요.

예제 (Examples)

Generic

../../_images/grafana_generic.png

Network

../../_images/grafana_network.png

Policy

../../_images/grafana_policy.png

../../_images/grafana_policy2.png

Endpoints

../../_images/grafana_endpoints.png

Controllers

../../_images/grafana_controllers.png

Kubernetes

../../_images/grafana_k8s.png

Hubble General Processing

../../_images/grafana_hubble_general_processing.png

Hubble Networking

Note

port-distribution 메트릭은 기본적으로 비활성화되어 있어요. 개별 메트릭에 대한 자세한 내용은 모니터링 & 메트릭을 참고하세요.

../../_images/grafana_hubble_network.png

../../_images/grafana_hubble_tcp.png

../../_images/grafana_hubble_icmp.png

Hubble DNS

../../_images/grafana_hubble_dns.png

Hubble HTTP

../../_images/grafana_hubble_http.png

Hubble Network Policy

../../_images/grafana_hubble_network_policy.png

더 알아보기 (Learn more)