- 사전 준비
kubectl, minikube, docker desktop 사전 설치 필요
- Grafana 설치
1. https://artifacthub.io/ 접속
2. grafana 검색
3. grafana (Grafana) 클릭
4. Helm repo 추가
helm repo add {Repo Name} https://grafana.github.io/helm-charts helm repo update
5. Repo Name 'grafana'로 설치하면 아래와 같은 설치 내용이 나온다.
"grafana" has been added to your repositories
6. 아래 명령어로 설치: Release Name은 개인적으로 설정
helm install {Release Name} grafana/grafana
7. Release Name 'my-grafana' 설치하면 아래와 같은 설치 내용이 나온다. (helm status {Release Name}으로 확인 가능)
NAME: my-grafana LAST DEPLOYED: Sat Apr 29 17:47:23 2023 NAMESPACE: default STATUS: deployed REVISION: 1 NOTES: 1. Get your 'admin' user password by running: kubectl get secret --namespace default my-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo 2. The Grafana server can be accessed via port 80 on the following DNS name from within your cluster: my-grafana.default.svc.cluster.local Get the Grafana URL to visit by running these commands in the same shell: export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=grafana,app.kubernetes.io/instance=my-grafana" -o jsonpath="{.items[0].metadata.name}") kubectl --namespace default port-forward $POD_NAME 3000 3. Login with the password from step 1 and the username: admin ################################################################################# ###### WARNING: Persistence is disabled!!! You will lose your data when ##### ###### the Grafana pod is terminated. ##### #################################################################################
8. kubectl get all 입력해보면 아래와 같이 service 및 pod가 실행되어 있는 것을 확인할 수 있다.
NAME READY STATUS RESTARTS AGE pod/my-grafana-6b4558754f-frdzh 1/1 Running 0 2m33s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 8d service/my-grafana ClusterIP 10.96.17.250 <none> 80/TCP 2m33s NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/my-grafana 1/1 1 1 2m33s NAME DESIRED CURRENT READY AGE replicaset.apps/my-grafana-6b4558754f 1 1 1 2m33s
9. 하지만, Grafana 서비스 접속을 위한 설정 변경이 필요하다. Helm Chart를 통해 변경한다.
git clone https://github.com/grafana/helm-charts.git cd helm-charts/charts/grafana vi values.yaml
10. 비밀번호 변경
# Administrator credentials when not using an existing secret (see below) adminUser: admin adminPassword: admin
11. Warning 이슈(PV) 해결
NAME: my-grafana LAST DEPLOYED: Sat Apr 29 17:47:23 2023 NAMESPACE: default STATUS: deployed REVISION: 1 NOTES: 1. Get your 'admin' user password by running: kubectl get secret --namespace default my-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo 2. The Grafana server can be accessed via port 80 on the following DNS name from within your cluster: my-grafana.default.svc.cluster.local Get the Grafana URL to visit by running these commands in the same shell: export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=grafana,app.kubernetes.io/instance=my-grafana" -o jsonpath="{.items[0].metadata.name}") kubectl --namespace default port-forward $POD_NAME 3000 3. Login with the password from step 1 and the username: admin ################################################################################# ###### WARNING: Persistence is disabled!!! You will lose your data when ##### ###### the Grafana pod is terminated. ##### #################################################################################
## Enable persistence using Persistent Volume Claims ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ ## persistence: type: pvc enabled: true # storageClassName: default accessModes: - ReadWriteOnce
12. values.yaml 수정 완료
13. 해당 values.yaml 파일로 my-grafana를 업그레이드 해야한다.helm upgrade my-grafana grafana/grafana -f values.yaml
14. 업그레이드 후 아래와 같은 내용이 나온다.
- 업그레이드가 성공적으로 마무리된 것을 확인할 수 있다.
REVISION: 2로 변경되었고, Warning 또한 사라졌다.Release "my-grafana" has been upgraded. Happy Helming! NAME: my-grafana LAST DEPLOYED: Sat Apr 29 18:18:22 2023 NAMESPACE: default STATUS: deployed REVISION: 2 NOTES: 1. Get your 'admin' user password by running: kubectl get secret --namespace default my-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo 2. The Grafana server can be accessed via port 80 on the following DNS name from within your cluster: my-grafana.default.svc.cluster.local Get the Grafana URL to visit by running these commands in the same shell: export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services my-grafana) export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT 3. Login with the password from step 1 and the username: admin
helm history my-grafana REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION 1 Sat Apr 29 17:47:23 2023 superseded grafana-6.56.1 9.5.1 Install complete 2 Sat Apr 29 18:18:22 2023 deployed grafana-6.56.1 9.5.1 Upgrade complete
# 비밀번호 변경 확인 kubectl get secret --namespace default my-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
15. 포트포워딩 설정
kubectl port-forward --namespace default svc/my-grafana 3000:80
16. Web UI 접속
http://localhost:3000/login
'Kubernetes' 카테고리의 다른 글
[Kubernetes] Kubernetes 클러스터 외부에서 관리하기 (Bastion, Local) (0) | 2024.05.27 |
---|---|
[Rancher] Kubernetes 클러스터 구축 (0) | 2024.05.23 |
[Kubernetes] 클러스터 운영 시 고려 사항 (0) | 2024.04.03 |
[Helm] grafana와 redis 연동하기 (0) | 2023.04.29 |
[Helm] redis 설치하기 (0) | 2023.04.29 |