EKS prometheus와 AWS Managed Prometheus 연동 예제
NAMESPACE="prometheus"
kubectl create ns $NAMESPACE
CLUSTER_NAME="basic-cluster"
eksctl utils associate-iam-oidc-provider --cluster ${CLUSTER_NAME} --approve
NAMESPACE="prometheus"
EKS_CLUSTER_NAME="basic-cluster"
SERVICEACCOUNT_NAME="amp-iamproxy-ingest-role"
eksctl create iamserviceaccount \
--name ${SERVICEACCOUNT_NAME} \
--namespace ${NAMESPACE} \
--cluster ${EKS_CLUSTER_NAME} \
--attach-policy-arn arn:aws:iam::aws:policy/AmazonPrometheusRemoteWriteAccess \
--approve
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
eks_cluster_name="test-eks"
irsa_serviceaccount="amp-iamproxy-ingest-role"
amp_workspace_id=$(aws amp list-workspaces --alias $eks_cluster_name | jq .workspaces[0].workspaceId -r)
aws_region="ap-northeast-2"
cat <<EOT > values.yaml
alertmanager:
enabled: false
grafana:
enabled: false
prometheus:
serviceAccount:
create: false
name: $irsa_serviceaccount
ingress:
enabled: false
prometheusSpec:
podMonitorSelectorNilUsesHelmValues: false
serviceMonitorSelectorNilUsesHelmValues: false
retention: 1d
retentionSize: "10GiB"
scrapeInterval: 15s
evaluationInterval: 15s
remoteWrite:
- url: https://aps-workspaces.$aws_region.amazonaws.com/workspaces/$amp_workspace_id/api/v1/remote_write
sigv4:
region: $aws_region
queueConfig:
maxSamplesPerSend: 1000
maxShards: 200
capacity: 2500
EOT
NAMESPACE="prometheus"
helm upgrade --install kube-prometheus-stack prometheus-community/kube-prometheus-stack \
--namespace ${NAMESPACE} \
--version 45.7.1 \
-f values.yaml
- error로그가 없어야 함
NAMESPACE="prometheus"
kubectl -n ${NAMESPACE} logs -f
helm uninstall -n prometheus kube-prometheus-stack