Search

Prometheus & Grafana

수집 → 필터링 → 저장 → 검색

ENV

EKS_CLUSTER_NAME="<CLUSTER_NAME>" CLUSTER_OIDC=$(aws eks describe-cluster --name $EKS_CLUSTER_NAME --query "cluster.identity.oidc.issuer" --output text | cut -c 9-100) AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query "Account" --output text)
Shell
복사

Prometheus

Metrics server

kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml kubectl get deployment metrics-server -n kube-system
Shell
복사

Namespace

kubectl create ns monitoring
Shell
복사

Prometheus Install

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update helm repo list helm install prometheus prometheus-community/prometheus \ --namespace monitoring \ --set alertmanager.persistentVolume.storageClass="gp2" \ --set server.persistentVolume.storageClass="gp2" \ -f values.yaml # 깃허브 참고
Shell
복사
kubectl get all -n monitoring
Shell
복사

EBS CSI Driver

OIDC

eksctl utils associate-iam-oidc-provider --region ap-northeast-2 --cluster $EKS_CLUSTER_NAME --approve
Shell
복사

IRSA

eksctl create iamserviceaccount \ --name ebs-csi-controller-sa \ --region ap-northeast-2 \ --namespace kube-system \ --cluster $EKS_CLUSTER_NAME \ --role-name AmazonEKS_EBS_CSI_DriverRole \ --role-only \ --attach-policy-arn arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy \ --approve
Shell
복사

Create Addon

eksctl create addon --name aws-ebs-csi-driver --cluster $EKS_CLUSTER_NAME --service-account-role-arn arn:aws:iam::$AWS_ACCOUNT_ID:role/AmazonEKS_EBS_CSI_DriverRole # eksctl delete addon --name aws-ebs-csi-driver --cluster $EKS_CLUSTER_NAME eksctl get addon --name aws-ebs-csi-driver --cluster $EKS_CLUSTER_NAME
Shell
복사

Grafana

Grafana Install

helm repo add grafana https://grafana.github.io/helm-charts helm repo update helm install grafana grafana/grafana \ --namespace monitoring \ --set persistence.storageClassName="gp2" \ --set persistence.enabled=true \ --set adminPassword='admin1234' \ --values prometheus-source.yaml \ --set service.type=ClusterIP
Shell
복사
prometheus-source.yaml
datasources: datasources.yaml: apiVersion: 1 datasources: - name: Prometheus type: prometheus url: http://prometheus-server.monitoring.svc.cluster.local/prometheus access: proxy isDefault: true
YAML
복사

Ingress (서브넷 Tag 지정해주기)

public subnet 키 : kubernetes.io/role/elb && 값 : 1
private subnet 키 : kubernetes.io/role/internal-elb && 값 : 1
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: ingress-monitoring namespace: monitoring annotations: alb.ingress.kubernetes.io/load-balancer-name: skills-alb alb.ingress.kubernetes.io/group.name: monitoring alb.ingress.kubernetes.io/scheme: internet-facing alb.ingress.kubernetes.io/target-type: ip alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}]' spec: ingressClassName: alb rules: - http: paths: - path: /prometheus pathType: Prefix backend: service: name: prometheus-server port: number: 80 - path: / pathType: Prefix backend: service: name: grafana port: number: 80
YAML
복사
kubectl apply -f monitoring-ingress.yaml
Shell
복사
동일한 alb dns에 구성
grafana
prometheus