관리 메뉴

피터의 개발이야기

[helm] helm으로 redis, grafana 설치과정 본문

Kubernetes/Helm

[helm] helm으로 redis, grafana 설치과정

기록하는 백앤드개발자 2023. 4. 19. 06:56
반응형

 

 

ㅁ 개요

helm의 장점을 소개하기 위해 helm으로 Redis와 Grafana를 설치하는 과정을 정리하게 되었다. 이전 글에서 설명하였듯이 kubernetes를 위한 패키지 관리 도구로, apt, yum 툴처럼 플랫폼의 패키지를  kubernetes의 오브젝트들의 구성체인 yaml을 패키지 형태로 관리한다.

 

 

ㅁ 내가 느낀 장점

1.  yaml 작성에 대한 부담감을 해소한다. 이미 검증된 helm의 template에 value의 값을 치환하면 된다. 쿠버네티스의 관리를 위해 많은 YAML파일들이 존재하는데, helm은 이들의 관리를 도와주는 역할을 수행하고 있다.

 

2. 몰랐던 기능은 보너스: value의 주석을 보면 해당 예전에 몰랐던 다양한 기능들을 알 수가 있다. template에서 제공하는 다양한 옵션들은 나에게 쿠버네티스 Object들의 숨겨진 기능에 대한 설명으로 느껴졌다. 예전 글, [Helm] Helm으로 jenkins 설치하기에서 jenkins를 helm으로 설치 시 value의 주석들을 보면 jenkins item을 백업하기 위한 옵션이 있었다. 논란부분은 이 옵션에 AWS S3 정보를 입력하면 백업 정보를 AWS S3에 저장하는 기능도 있었다.

 

 

ㅁ helm의 명령어 공부

 ㅇ helm의 공식문서를 통해 명령어 사용법을 확인할 수 있다. 이곳

 

 

ㅁ helm search

  ㅇ ArtifactHUB로 이동하여 Redis를 검색한다.

 ㅇ redis 설치를 위한 Helm chart의 목록을 순위별로 확인 할 수 있다.

 

 ㅇ Helm chart 화면으로 진입하면 chart의 사용법 및 버젼정보와 사용 빈도를 확인할 수 있다.

 

 

ㅁ Single Or Cluster Helm Chart

 ㅇ Redis의 클러스터 모드에 대해서 설명하고 선택하도록 안내하고 있다.

 ㅇ 테스트를 위해 단일 Master 버젼으로 설치한다.

 ㅇ 자세한 것인 이곳

 

 

ㅁ Helm Install

 ㅇ my-release라는 이름으로 설치하였다.

❯ helm install my-release bitnami/redis
NAME: my-release
LAST DEPLOYED: Tue Apr 18 12:52:51 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: redis
CHART VERSION: 17.9.5
APP VERSION: 7.0.11

** Please be patient while the chart is being deployed **

Redis® can be accessed on the following DNS names from within your cluster:

    my-release-redis-master.default.svc.cluster.local for read/write operations (port 6379)
    my-release-redis-replicas.default.svc.cluster.local for read-only operations (port 6379)



To get your password run:

    export REDIS_PASSWORD=$(kubectl get secret --namespace default my-release-redis -o jsonpath="{.data.redis-password}" | base64 -d)

To connect to your Redis® server:

1. Run a Redis® pod that you can use as a client:

   kubectl run --namespace default redis-client --restart='Never'  --env REDIS_PASSWORD=$REDIS_PASSWORD  --image docker.io/bitnami/redis:7.0.11-debian-11-r0 --command -- sleep infinity

   Use the following command to attach to the pod:

   kubectl exec --tty -i redis-client \
   --namespace default -- bash

2. Connect using the Redis® CLI:
   REDISCLI_AUTH="$REDIS_PASSWORD" redis-cli -h my-release-redis-master
   REDISCLI_AUTH="$REDIS_PASSWORD" redis-cli -h my-release-redis-replicas

To connect to your database from outside the cluster execute the following commands:

    kubectl port-forward --namespace default svc/my-release-redis-master 6379:6379 &
    REDISCLI_AUTH="$REDIS_PASSWORD" redis-cli -h 127.0.0.1 -p 6379

 

ㅇ redis-cli pod에서 shell 접속 

redis-cli -h 10.1.0.14 -p 6379 -a C9NAHQRi6N

 

ㅁ grafana 설치

 ㅇ 이곳 참조

 

 

❯ helm install gfn grafana/grafana -f values.yaml --namespace monitor
NAME: gfn
LAST DEPLOYED: Tue Apr 18 13:44:22 2023
NAMESPACE: monitor
STATUS: deployed
REVISION: 1
NOTES:
1. Get your 'admin' user password by running:

   kubectl get secret --namespace monitor gfn-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:

   gfn-grafana.monitor.svc.cluster.local

   Get the Grafana URL to visit by running these commands in the same shell:
     export POD_NAME=$(kubectl get pods --namespace monitor -l "app.kubernetes.io/name=grafana,app.kubernetes.io/instance=gfn" -o jsonpath="{.items[0].metadata.name}")
     kubectl --namespace monitor port-forward $POD_NAME 3000

3. Login with the password from step 1 and the username: admin

 

 

ㅁ Redis Plugin 설치

 ㅇ Grafana는 plugin 형태로 다양한 기능을 추가하여 사용할 수 있다.

 ㅇ Redis모니터링을 위한 연동을 위해 Redis와 Redis Application plugin을 설치하였다.

 

 

ㅁ DataSource 세팅

 ㅇ Data Sorces를 설정한 후 Dashboard를 탭을 클릭하여 바로 dashboard를 추가할 수 있다.

 

ㅇ 현재는 이미 import한 상태이다.

ㅇ Dashboard를 생성하는 과정에는 직접적인 방법과 dashboard를 import하는 방법이 있다.

 

 

ㅁ Dashboard 생성

 

 

ㅁ Dashboard 검색하기 

 ㅇ Dashboard를 직접 구성할 수도 있지만 처음에는 이미 만들어 놓은 다양한 Dashboard 검색하여 import하는 방법도 있다.

  ㅇ https://grafana.com/grafana/dashboards/?search=redis

 ㅇ 다운로드 수가 가장 많은 Redis를 클릭하였습니다.

 

 

 ㅇ Copy ID to clipboard를 클릭하여 12776 ID를 복사합니다.

 

 

 

 ㅇ Dashboard에 복사를 합니다.

 

 ㅇ 이름과 Datasource를 연결합니다.

 

 

 ㅇ Dashboard 완성!!

 

 

 

ㅁ 마무리

 ㅇ JAVA 개발자로 성장하면서 다양한 기술이 집약된 Spring을 만나 공부하고 이를 통해 많은 일을 할 수 있었습니다.

 ㅇ IT환경의 성장에 따라 더 많은 트래픽이 발생하고 다양한 아키텍쳐들이 생겨나고 있습니다.

 ㅇ 개발자 커뮤니티에서는 다양한 아키텍쳐를 쉽게 사용할 수 있도록 커뮤니티가 구성되어 있어서, 이를 잘 활용한다면 다양한 아키텍쳐들을 배울 수 있는 기회라고 생각합니다.

 ㅇ 코드형 인프라(Infrastructure as Code, IaC)는 수동 프로세스가 아닌 코드를 통해 인프라를 관리하고 프로비저닝하는 것을 말합니다.

 ㅇ 백엔드 개발자인 저는 인프라 영역에도 지속적으로 공부하고 인프라를 더 쉽고 빠르게 프로비저닝 하려고 노력합니다.

반응형
Comments