반응형

 

 

multipass 로 설치한 k3s 에 grafana 와 prometheus 를 설치한다. 이를 위해 k3s 가 설치되어 있어야 한다.

https://jjoyling.tistory.com/197

 

K3S 설치 - mac (multipass)

mutlpass 설치brew install --cask multipassmultipass 설치 확인k3s 설치를 위한 가상머신 생성#multiupass launch -> Ubuntu 20.04 가상머신 생성multipass launch --name k3s --memory 2048M --disk 10G focal#multipass list -> 가상머신 설

jjoyling.tistory.com

 

 

k3s kubeconfig 설정

/etc/rancher/k3s/k3s.yaml 정보를 ./kubeconfig 파일로 복사한다.
파일 내부에 서버 정보를 multipass IP 로 변경해준다.
설정이 완료되면 multipass 접속 없이 맥북 터미널에서 조작이 가능하다.

multipass list
Name                    State             IPv4             Image
k3s                     Running           192.168.64.2     Ubuntu 20.04 LTS
                                          10.42.0.0
                                          10.42.0.1

# kubeconfig 파일 내부 변경
server: https://192.168.64.2:6443

# kubeconfig 설정 후 kubectl 명령어 사용
export KUBECONFIG=./kubeconfig
kubectl get all
NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
service/kubernetes   ClusterIP   10.43.0.1    <none>        443/TCP   53m


Prometheus 설치

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

# 네임스페이스 생성
kubectl create namespace mon

# Helm Chart로 Prometheus 설치
helm install prometheus prometheus-community/prometheus \
  --namespace mon

helm chart 를 이용하여 prometheus 설치 완료 , 접근하여 설치 확인

kubectl port-forward -n mon svc/prometheus-server 9090:80

prometheus-server 서비스를 9090 포트로 포워딩하여 맥북에서 localhost:9090 으로 확인이 가능함.

 

grafana 설치

helm repo add grafana https://grafana.github.io/helm-charts
helm repo update

# 네임스페이스 생성 (이미 monitoring 네임스페이스가 있다면 생략 가능)
kubectl create namespace mon

# Grafana 설치
helm install grafana grafana/grafana \
  --namespace mon \
  --set adminPassword=admin \
  --set service.type=NodePort

grafana 관련 서비스가 생성됨, 접속해보자.

kubectl get svc -n mon | grep grafana
grafana                               NodePort    10.43.86.133    <none>        80:31527/TCP   18m

서비스를 조회해보면 31527 포트로 NodePort 서비스가 생성되어 있다.
multipass 인스턴스의 31527 포트로 접속이 가능하다는 의미이다. multipass IP 를 확인해보자.
설치 시 설정한 초기 계정은 admin/admin 이다.

내 mac 에서는 192.168.64.2:31527 로 접속이 가능하다.

 

반응형