- 사전 준비
kubectl, minikube, docker desktop 사전 설치 필요
- Redis 설치
1. https://artifacthub.io/ 접속
2. redis 검색
3. redis (Bitnami) 클릭
4. 아래 명령어로 설치: Release Name은 개인적으로 설정
helm install {Release Name} oci://registry-1.docker.io/bitnamicharts/redis
5. Release Name 'my-release' 설치하면 아래와 같은 설치 내용이 나온다. (helm status {Release Name}으로 확인 가능)
Pulled: registry-1.docker.io/bitnamicharts/redis:17.10.1 Digest: sha256:352767b978ba54dff73aab7c80c6a7140a9fa9bbbb8faafcb8612bfad932d2e5 NAME: my-release LAST DEPLOYED: Sat Apr 29 16:46:46 2023 NAMESPACE: default STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: CHART NAME: redis CHART VERSION: 17.10.1 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
6. kubectl get all 입력해보면 아래와 같이 service 및 pod가 실행되어 있는 것을 확인할 수 있다.
NAME READY STATUS RESTARTS AGE pod/my-release-redis-master-0 1/1 Running 0 35m pod/my-release-redis-replicas-0 1/1 Running 0 35m pod/my-release-redis-replicas-1 1/1 Running 0 34m pod/my-release-redis-replicas-2 1/1 Running 0 34m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 8d service/my-release-redis-headless ClusterIP None <none> 6379/TCP 35m service/my-release-redis-master ClusterIP 10.103.65.146 <none> 6379/TCP 35m service/my-release-redis-replicas ClusterIP 10.99.242.91 <none> 6379/TCP 35m NAME READY AGE statefulset.apps/my-release-redis-master 1/1 35m statefulset.apps/my-release-redis-replicas 3/3 35m
7. 환경 변수에 비밀번호 저장
export REDIS_PASSWORD=$(kubectl get secret --namespace default my-release-redis -o jsonpath="{.data.redis-password}" | base64 -d)
8. 환경 변수 비밀번호 확인
echo $REDIS_PASSWORD
9. 포트포워딩 설정
kubectl port-forward --namespace default svc/my-release-redis-master 6379:6379
10. 새로운 cmd로 redis 접속 확인
redis-cli -h 127.0.0.1 -p 6379 --askpass 비밀번호 입력 후 접속 확인
'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] grafana 설치하기 (0) | 2023.04.29 |