OpenAgent 구성
OpenAgent는 프로메테우스 엔드포인트에서 메트릭을 스크래핑하고, 이를 처리하여 와탭 서버로 전송하는 역할을 합니다. 프로메테우스 엔드포인트에서 메트릭을 수집하고 와탭 서버로 전송하는 Go 기반 에이전트입니다.
설정
단독 yaml로 설치하는 경우
기본적으로 오픈 에이전트는 whatap-monitoring 네임스페이스에 생성됩니다. 필요에 따라 조정할 수 있습니다.
# Whatap Open Agent standalone manifests
# 네임스페이스는 필요에 따라 조정하세요. 예시로 whatap-monitoring을 사용합니다.
---
#apiVersion: v1
#kind: Namespace
#metadata:
# name: whatap-monitoring
---
# Whatap 접속 정보 (라이센스/호스트/포트)
# 이미 동일한 이름의 Secret을 별도로 만들어 두었다면 이 Secret 블록을 삭제하고,
# 아래 Deployment의 secretKeyRef.name을 기존 Secret 이름과 맞추면 됩니다.
apiVersion: v1
kind: Secret
metadata:
name: whatap-open-credentials
namespace: whatap-monitoring
type: Opaque
stringData:
WHATAP_LICENSE: "<YOUR_LICENSE>"
WHATAP_HOST: "<WHATAP_HOST>"
WHATAP_PORT: "6600"
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: whatap-open-agent-sa
namespace: whatap-monitoring
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: whatap-open-agent-role
rules:
- apiGroups: ["*"]
resources: ["pods", "services", "endpoints", "endpointslices", "namespaces", "secrets"]
verbs: ["get", "list", "watch"]
- nonResourceURLs: ["/metrics"]
verbs: ["*"]
- apiGroups: [""]
resources: ["pods/exec"]
verbs: ["create"]
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["*"]
- nonResourceURLs: ["/metrics"]
verbs: ["*"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: whatap-open-agent-role-binding
subjects:
- kind: ServiceAccount
name: whatap-open-agent-sa
namespace: whatap-monitoring
roleRef:
kind: ClusterRole
name: whatap-open-agent-role
apiGroup: rbac.authorization.k8s.io
---
apiVersion: v1
kind: ConfigMap
metadata:
name: whatap-open-agent-config
namespace: whatap-monitoring
data:
scrape_config.yaml: |
features:
openAgent:
enabled: true
globalInterval: "60s"
globalPath: "/metrics"
targets:
- targetName: kube-apiserver
type: ServiceMonitor
namespaceSelector:
matchNames:
- "default" # API 서버 서비스가 있는 네임스페이스로 변경
selector:
matchLabels:
component: apiserver
provider: kubernetes
endpoints:
- port: "https"
path: "/metrics"
interval: "30s"
scheme: "https"
timeout: "30s"
tlsConfig:
insecureSkipVerify: true
metricRelabelConfigs:
- source_labels: [__name__]
regex: "apiserver_request_total"
action: keep
- source_labels: [verb]
target_label: http_verb
replacement: "${1}"
action: replace
- target_label: metric_src
replacement: "whatap-open-agent"
action: replace
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: whatap-open-agent
namespace: whatap-monitoring
labels:
name: whatap-open-agent
spec:
replicas: 1
selector:
matchLabels:
name: whatap-open-agent
template:
metadata:
labels:
name: whatap-open-agent
spec:
serviceAccountName: whatap-open-agent-sa
volumes:
- name: config-volume
configMap:
name: whatap-open-agent-config
- name: logs-volume
emptyDir: {}
containers:
- name: whatap-open-agent
image: public.ecr.aws/whatap/open_agent:latest
imagePullPolicy: Always
resources:
requests:
memory: "300Mi"
cpu: "100m"
limits:
memory: "1000Mi"
cpu: "1000m"
env:
- name: WHATAP_LICENSE
valueFrom:
secretKeyRef:
name: whatap-open-credentials
key: WHATAP_LICENSE
- name: WHATAP_HOST
valueFrom:
secretKeyRef:
name: whatap-open-credentials
key: WHATAP_HOST
- name: WHATAP_PORT
valueFrom:
secretKeyRef:
name: whatap-open-credentials
key: WHATAP_PORT
- name: debug
value: "false"
volumeMounts:
- name: config-volume
mountPath: /app/scrape_config.yaml
subPath: scrape_config.yaml
- name: logs-volume
mountPath: /app/logs
# 필요 시 컨테이너/노드 톨러레이션, affinity 등을 추가하십시오.
helm 설치
-
다음 명령어를 실행해 와탭 Helm 리포지토리를 추가하세요.
helm repo add whatap https://whatap.github.io/helm/
helm repo update -
에이전트를 처음 설치하는 사용자는 다음 명령어를 실행해 에이전트 애플리케이션을 설치하세요. values.yaml은 아래 예시를 참고합니다.
- 처음 설치
- 기존 사용자
#에이전트를 처음 설치하는 사용자는 다음 명령어를 실행해 에이전트 애플리케이션을 설치하세요.
kubectl create ns whatap-monitoring
helm install whatap-kube-agent --namespace whatap-monitoring whatap/kube -f values.yaml#기존 와탭 쿠버네티스 에이전트 사용자는 다음 명령어를 실행해 에이전트를 설치하세요.
#*기존 yaml 파일 방식으로 와탭 쿠버네티스 에이전트를 설치한 경우 Clean Install이 필요합니다. 기존 쿠버네티스 에이전트 삭제 후 Helm 차트를 통한 설치가 가능합니다.
kubectl delete ns whatap-monitoring
kubectl delete clusterrole whatap
kubectl delete clusterrolebinding whatap
kubectl create ns whatap-monitoring
helm install whatap-kube-agent --namespace whatap-monitoring whatap/kube -f values.yaml
values.yaml
whatap:
license: #라이센스 키 입력
host: #수집서버 IP 입력
port: #수집서버 Port 입력
createSecret: true #default : true, if credentials already exist, set false
existingSecretName: "whatap-credentials" #default : whatap-credentials
collect_custom_resources: true
containerRuntime: "containerd"
deployment:
containers:
controlPlaneHelper:
enabled: false
image: "whatap/kube_mon:1.8.8"
name: "whatap-control-plane-helper"
port: 9496
resources:
limits:
cpu: "200m"
memory: "350Mi"
requests:
cpu: "100m"
memory: "300Mi"
masterAgent:
image: "whatap/kube_mon:1.8.8"
name: "whatap-master-agent"
port: 6600
resources:
limits:
cpu: "200m"
memory: "350Mi"
requests:
cpu: "100m"
memory: "300Mi"
label: "whatap-master-agent"
name: "whatap-master-agent"
replicas: 1
daemonSet:
containers:
nodeAgent:
image: "whatap/kube_mon:1.8.8"
limits:
cpu: "200m"
memory: "350Mi"
name: "whatap-node-agent"
requests:
cpu: "100m"
memory: "300Mi"
nodeHelper:
image: "whatap/kube_mon:1.8.8"
limits:
cpu: "200m"
memory: "350Mi"
name: "whatap-node-helper"
requests:
cpu: "100m"
memory: "100Mi"
initContainers:
nodeDebugger:
enabled: false
image: "whatap/kube_mon:1.8.8"
name: "whatap-node-debug"
label: "whatap-node-agent"
name: "whatap-node-agent"
clusterrole:
extraResources:
- "*"
deploymentOpen:
enabled: true
containers:
openAgent:
image: "public.ecr.aws/whatap/open_agent:latest"
config:
features:
openAgent:
enabled: true
#globalInterval: "60s"
#globalPath: "/metrics"
targets:
- targetName: "kube-apiserver"
type: "ServiceMonitor"
enabled: true
namespaceSelector:
matchNames:
- "default" # 클러스터 기본 레이블에 맞게 조정
selector:
matchLabels:
component: "apiserver"
provider: "kubernetes"
endpoints:
- port: "https"
path: "/metrics"
interval: "30s"
scheme: "https"
timeout: "30s"
tlsConfig:
insecureSkipVerify: true # 자체서명 인증서일 때 편의용, 보안 필요 시 false + CA 지정
metricRelabelConfigs:
- source_labels: [__name__]
regex: "apiserver_request_total"
action: keep
- source_labels: [verb]
target_label: http_verb
replacement: "${1}"
action: replace
- target_label: metric_src
replacement: "whatap-open-agent"
action: replace
WhatapOperator 설치 후, 사용자는 WhatapAgent CR(Custom Resource)을 통해 OpenMetrics 대상을 설정합니다.
-
PodMonitor: Pod 레이블 셀렉터를 이용한 동적 디스커버리 (Prometheus Operator의 PodMonitor와 유사)
-
ServiceMonitor: Service 레이블 셀렉터를 이용한 동적 디스커버리 (Prometheus Operator의 ServiceMonitor와 유사)
-
StaticEndpoints: 고정된 IP 주소와 포트를 직접 입력 (Prometheus의 static_configs와 유사)
features:
openAgent:
enabled: true
targets:
# 1. PodMonitor: Pod 레이블 셀렉터를 이용한 동적 디스커버리
- targetName: my-app-pod-metrics
type: PodMonitor
namespaceSelector:
matchNames:
- "production"
selector:
matchLabels:
app: my-app
endpoints:
- port: "web-metrics" # Pod Spec에 정의된 Port 이름 또는 실제 Port 번호
path: "/metrics" # 기본값은 /metrics, 필요시 재정의
interval: "15s" # 기본값은 전역 설정, 필요시 재정의
scheme: "http"
timeout: "10s"
metricRelabelConfigs: # 스크래핑 후 메트릭 재라벨링 설정
- source_labels: [__name__]
regex: "http_requests_total"
action: keep
- source_labels: [method]
target_label: http_method
replacement: "${1}"
action: replace
# 2. ServiceMonitor: Service 레이블 셀렉터를 이용한 동적 디스커버리
- targetName: my-service-metrics
type: ServiceMonitor
namespaceSelector:
matchNames:
- "default"
selector:
matchLabels:
service: my-backend-service
endpoints:
- port: "http-metrics" # Service Spec에 정의된 Port 이름 또는 실제 Target Port 번호
path: "/actuator/prometheus"
interval: "30s"
metricRelabelConfigs:
- source_labels: [__name__]
regex: "jvm_.*"
action: keep
- source_labels: [area]
target_label: memory_area
replacement: "${1}"
action: replace
# 3. StaticEndpoints: 고정된 IP 주소와 포트를 직접 입력
- targetName: my-external-db-metrics
type: StaticEndpoints
# enabled: true # 타겟 활성화 여부 (기본값: true, 생략 가능)
endpoints:
- address: "192.168.1.100:9100"
scheme: "http"
path: "/metrics"
interval: "60s"
metricRelabelConfigs:
- source_labels: [__name__]
regex: "node_(cpu|memory).*"
action: keep
- source_labels: [instance]
target_label: server
replacement: "${1}"
action: replace
PodMetrics 및 ServiceMetrics 설정 요소
-
targetName: 타겟의 이름(로깅 및 식별용)
-
type: 타겟 유형("PodMetrics" 또는 "ServiceMetrics")
-
namespaceSelector: 스크래핑할 네임스페이스
matchNames: 이름으로 네임스페이스 선택matchLabels: 레이블로 네임스페이스 선택matchExpressions: 표현식으로 네임스페이스 선택
-
selector: 스크래핑할 파드 또는 서비스 선택
matchLabels: 레이블로 파드 또는 서비스 선택matchExpressions: 표현식으로 파드 또는 서비스 선택
-
relabelConfigs: 타겟 발견(Discovery) 단계에서 메타데이터(meta 라벨 등)를 기반으로 라벨을 추가하거나 변경합니다.(프로메테우스의
relabel_configs와 유사) -
endpoints: 스크래핑할 엔드포인트 정의
port: 스크래핑할 포트 이름 또는 번호path: 메트릭 경로(기본값은 globalPath, 필요시 재정의)interval: 스크래핑 간격(기본값은 globalInterval, 필요시 재정의)scheme: 스크래핑 프로토콜(http 또는 https, 기본값 http)timeout: 스크래핑 타임아웃honorLabels: 대상에서 제공하는 레이블을 우선시할지 여부metricRelabelConfigs: 스크래핑 후 메트릭 재라벨링 설정(프로메테우스의 metric_relabel_configs와 유사)
StaticEndpoints 설정 요소
-
targetName: 타겟의 이름(로깅 및 식별용)
-
type: 타겟 유형("StaticEndpoints")
-
endpoints: 스크래핑할 엔드포인트 정의
-
address: 스크래핑할 대상 주소 (IP:PORT 또는 HOSTNAME:PORT) -
path: 메트릭 경로 (기본값: /metrics) -
scheme: 스크래핑 프로토콜 (http 또는 https, 기본값 http) -
interval: 스크래핑 간격 (기본값: 60s) -
tlsConfig: TLS 설정 -
metricRelabelConfigs: 스크래핑 후 메트릭 재라벨링 설정
-
addNodeLabel 기능
스크랩 대상이 노드에 스케쥴링 되어 있는 경우 addNodeLabel 옵션을 사용하여 스케줄링된 노드의 이름을 메트릭에 라벨로 추가할 수 있습니다.
-
설정 위치: 타겟 레벨 또는 엔드포인트 레벨에서 설정 가능
-
기본값:
false -
동작:
true로 설정하면 모든 메트릭에node라벨이 추가되며, 오브젝트가 실행 중인 노드의 이름이 값으로 추가됨
# 타겟 레벨에서 addNodeLabel 설정
- targetName: node-exporter
type: PodMonitor
namespaceSelector:
matchNames:
- "monitoring"
selector:
matchLabels:
app: node-exporter
endpoints:
- port: "metrics"
path: "/metrics"
interval: "30s"
addNodeLabel: true # 이 엔드포인트에 노드 라벨 추가
metricRelabelConfigs:
# 노드 라벨을 사용한 재라벨링 예제
- source_labels: [node]
target_label: kubernetes_node
action: replace
# 엔드포인트 레벨에서 addNodeLabel 설정
- targetName: dcgm-exporter
type: PodMonitor
namespaceSelector:
matchNames:
- "kube-system"
selector:
matchLabels:
app: dcgm-exporter
endpoints:
- port: "metrics"
path: "/metrics"
interval: "30s"
addNodeLabel: true # 이 엔드포인트에만 노드 라벨 추가
metricRelabelConfigs:
- source_labels: [node]
target_label: gpu_node
action: replace
Basic Auth 설정
OpenAgent는 인증이 필요한 엔드포인트를 스크래핑하기 위해 HTTP Basic Authentication을 지원합니다. 사용자 이름(username)과 비밀번호(password)는 Kubernetes Secret을 통해 안전하게 관리됩니다.
-
설정 위치: endpoints 하위의 basicAuth 항목에서 설정
-
username: 사용자 이름을 담고 있는 Secret 정보
name: Secret의 이름key: Secret 내의 Keynamespace: Secret이 위치한 네임스페이스 (생략 시 에이전트와 동일한 네임스페이스)
-
password: 비밀번호를 담고 있는 Secret 정보
name: Secret의 이름key: Secret 내의 Keynamespace: Secret이 위치한 네임스페이스
endpoints:
- port: "metrics"
path: "/metrics"
basicAuth:
username:
name: my-auth-secret
key: username
password:
name: my-auth-secret
key: password
namespace: monitoring # Secret이 다른 네임스페이스에 있는 경우 명시
TLS 설정
OpenAgent는 HTTPS 엔드포인트에 연결할 때 TLS(Transport Layer Security)를 지원합니다. 다음은 TLS 관련 설정 옵션입니다.
HTTP vs HTTPS 결정 방법
OpenAgent는 다음과 같은 규칙에 따라 HTTP 또는 HTTPS 프로토콜을 사용할지 결정합니다.
-
PodMonitor 및 ServiceMonitor 타겟
- 포트 이름이 "https"인 경우 기본적으로 HTTPS를 사용합니다.
- 그 외의 경우 기본적으로 HTTP를 사용합니다.
-
StaticEndpoints 타겟
- TLS 설정이 존재하는 경우 기본적으로 HTTPS를 사용합니다.
- 그 외의 경우 기본적으로 HTTP를 사용합니다.
-
모든 타겟 유형
- 엔드포인트나 타겟에 명시적으로
scheme설정이 있는 경우, 이 설정이 기본값을 재정의합니다.
- 엔드포인트나 타겟에 명시적으로