상세 컨텐츠

본문 제목

Azure AKS (에저 쿠버네티스 서비스) 에서 Prometheus (프로메테우스) 와 Grafana (그라파나) 설치 - Powershell

본문

Azure AKS에서 Prometheus (프로메테우스)와 Grafana (그라파나)를 윈도즈 환경에서 쉽게 설치하는 방법을 간단히 소개드리겠습니다.

쿠버네티스에서 Monitoring과 Alerting을 담당하는 부분은 Prometheus와 Grafana 가 쉽게 도와주고 있는데요. Prometheus는 AKS Monitor에서 로그를 가져와서 그래프같이 대시보드를 만들 수가 있습니다. 하지만 Prometheus를 사용하기가 어렵죠. 그래서 Grafana를 이용하는데 Grafana의 단점은 데이터소스가 필요하다는 것입니다. 그래서 Prometheus 나 Azure Monitor를 데이터 소스로 이용을 하면 쉽게 Grafana로 쿠버네티스 환경을 모니터링할 수 있는 대시보드를 쉽게 만들 수 있습니다.
 

반응형

1. Prerequisites - 준비사항


a. Windows 환경 (10이나 11)


b. Azure CLI

설치 방법은 https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-windows?tabs=azure-cli

 

Install the Azure CLI for Windows

To install the Azure CLI on Windows, you must use Powershell, or an MSI installer, which gives you access to the CLI through the Windows Command Prompt (CMD).

learn.microsoft.com


c. chocolatey

PowerShell에 여러 가지 툴들을 쉽게 설치하게 도와주는 프로그램입니다. 아래 링크에 방법이 있고 제가 따로 그 밑에 적어 두었습니다.
https://chocolatey.org/install

 

Installing Chocolatey

Chocolatey is software management automation for Windows that wraps installers, executables, zips, and scripts into compiled packages. Chocolatey integrates w/SCCM, Puppet, Chef, etc. Chocolatey is trusted by businesses to manage software deployments.

chocolatey.org

1. 먼저 PowerShell을 관리자 권한으로 열어주세요
2. 우선 아래 커맨드를 입력하여 주세요

Get-ExecutionPolicy

3. 리턴값이 Restricted 면 아래 두 커맨드 중 하나를 입력하세요. 아니면 다음번으로 가세요.

Set-ExecutionPolicy AllSigned
Set-ExecutionPolicy Bypass -Scope Process

4. 아래의 커맨드를 입력하여 설치합니다

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

d. helm과 base64

helm과 base64는 chocolatey라는 PowerShell 툴로 쉽게 설치 가능합니다.

choco install kubernetes-helm
choco install base64

Helm - https://github.com/helm/helm

 

GitHub - helm/helm: The Kubernetes Package Manager

The Kubernetes Package Manager. Contribute to helm/helm development by creating an account on GitHub.

github.com

base64 - https://community.chocolatey.org/packages/base64

 

Base64 encoder/decoder 1.0.0

a command-line Base64 tool

community.chocolatey.org

728x90

2. Instructions - 설치 순서


a. PowerShell을 열어주세요


b. Azure CLI로 계정 로그인과 구독 지정

az login
az account set --subscription <구독아이디 - <> 빼고>

c. kubectl (쿠벡틀) 계정을 다운로드하음

az aks get-credentials --name <AKS 클러스터 이름 - <> 빼고> --resource-group <AKS 클러스터 리소스 그룹 이름 - <> 빼고>

d. Prometheus와 Grafana 설치

다음 커맨드를 PowerShell에 하나씩 입력합니다.

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts

helm repo update

helm repo list

kubectl create ns prometheus

helm install prometheus prometheus-community/kube-prometheus-stack -n prometheus

kubectl get all -n prometheus

오류 없이 다 설치되었으면 완료입니다.


3. 설치 후 접근 방법


프로덕션 시스템에서는 Public IP와 DNS로 지정하여 접근하는 방식이고 그전에는 port forwarding 방식을 사용하여 브라우저 localhost 주소로 접근 가능합니다.


a. Prometheus 접근

아래 예제 커맨드를 PowerShell에 입력하면 브라우저로 localhost:9090 주소로 접근 가능합니다.

kubectl port-forward -n prometheus prometheus-prometheus-kube-prometheus-prometheus-0 9090

b. Grafana 접근

아래 예제 커맨드를 PowerShell에 입력하면 브라우저로 localhost:3000 주소로 접근 가능합니다. 우선은 그라파나에 로그인할 프로메테우스의 관리자 계정이 필요하니 아래 커멘드에 넣었습니다.

# 프로메테우스 관리자 유저이름
kubectl get secret -n prometheus prometheus-grafana -o=jsonpath='{.data.admin-user}' |base64 -d

# 프로메테우스 관리자 비밀번호
kubectl get secret -n prometheus prometheus-grafana -o=jsonpath='{.data.admin-password}' |base64 -d

# Port forward the Grafana service
kubectl port-forward -n prometheus <에저 AKS에 설치되어 있는 그라파나 POD 이름 - <> 빼고> 3000

그라파나에 접근과 로그인 성공 후 프로메테우스 관리자 계정 비밀번호를 바꿔주세요. 그라파나에서 가능합니다.


도움이 되셨거나 즐거우셨다면 아래의 ❤️공감버튼이나 구독버튼을 눌러 주세요~  감사합니다

 

 

728x90
반응형

관련글 더보기