Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- kotlin coroutine
- 공부
- CloudWatch
- PETERICA
- 정보처리기사실기 기출문제
- Linux
- 티스토리챌린지
- kotlin querydsl
- Pinpoint
- kotlin
- Java
- IntelliJ
- minikube
- kotlin spring
- aws
- 오블완
- Spring
- CKA 기출문제
- Elasticsearch
- 정보처리기사 실기
- AWS EKS
- mysql 튜닝
- AI
- CKA
- 정보처리기사 실기 기출문제
- Kubernetes
- MySQL
- 기록으로 실력을 쌓자
- APM
- 코틀린 코루틴의 정석
Archives
- Today
- Total
피터의 개발이야기
[Helm] MySQL 설치하기 본문
반응형
ㅁ 들어가며
데이터 마이그레이션 작업 시 임시적으로 MySql이 필요하여 helm으로 빠르게 설치하게 되었다. 그 과정에서 추가적으로 알아두면 좋은 점이 있어서 정리해 보았다.
ㅁ Helm repo 추가
$ helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories
ㅇ 차트 리포지토리 추가가 되었다.
$ helm search repo bitnami
ㅇ 리포지토리를 통해 설치가능 헬름 차트들의 목록과 설명을 확인 할 수 있다.
ㅁ helm install
$ helm install mysql-temp --set auth.rootPassword=tempopassword bitnami/mysql
ㅇ 문법구조: helm install {릴리스 이름} {옵션} {저장소 이름}/{차트 이름}
ㅇ root Password를 옵션으로 지정하였다.
NAME: mysql-temp
LAST DEPLOYED: Thu Jun 1 23:34:44 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: mysql
CHART VERSION: 9.10.1
APP VERSION: 8.0.33
** Please be patient while the chart is being deployed **
Tip:
Watch the deployment status using the command: kubectl get pods -w --namespace default
Services:
echo Primary: mysql-temp.default.svc.cluster.local:3306
Execute the following to get the administrator credentials:
echo Username: root
MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace default mysql-temp -o jsonpath="{.data.mysql-root-password}" | base64 -d)
To connect to your database:
1. Run a pod that you can use as a client:
kubectl run mysql-temp-client --rm --tty -i --restart='Never' --image docker.io/bitnami/mysql:8.0.33-debian-11-r12 --namespace default --env MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD --command -- bash
2. To connect to primary service (read/write):
mysql -h mysql-temp.default.svc.cluster.local -uroot -p"$MYSQL_ROOT_PASSWORD"
ㅁ mkdir: cannot create directory '/bitnami/mysql/data': Permission denied
$ kubectl logs mysql-temp-0
mysql 15:06:52.40
mysql 15:06:52.40 Welcome to the Bitnami mysql container
mysql 15:06:52.40 Subscribe to project updates by watching https://github.com/bitnami/containers
mysql 15:06:52.41 Submit issues and feature requests at https://github.com/bitnami/containers/issues
mysql 15:06:52.41
mysql 15:06:52.41 INFO ==> ** Starting MySQL setup **
mysql 15:06:52.42 INFO ==> Validating settings in MYSQL_*/MARIADB_* env vars
mysql 15:06:52.42 INFO ==> Initializing mysql database
mkdir: cannot create directory '/bitnami/mysql/data': Permission denied
ㅇ Pod가 생성되지 않아 log를 확인한 결과 data 폴더를 만드는 과정에서 permision denied가 발생하였다.
ㅇ 문제가 되었던 permission을 해결하기 위해 volumePermission을 true로 수정하였다.
ㅇ rootPassword도기존 옵션형태로 설정한 부분을 선언형으로 함께 설정하였다.
ㅁ helm uninstall
$ helm uninstall mysql-temp
release "mysql-temp" uninstalled
ㅇ 기존 설치된 mysql을 삭제하였다.
ㅁ reinstall
$ helm install mysql-temp -f values-mysql.yaml bitnami/mysql
NAME: mysql-temp
LAST DEPLOYED: Fri Jun 2 07:11:15 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: mysql
CHART VERSION: 9.10.1
APP VERSION: 8.0.33
** Please be patient while the chart is being deployed **
Tip:
Watch the deployment status using the command: kubectl get pods -w --namespace default
Services:
echo Primary: mysql-temp.default.svc.cluster.local:3306
Execute the following to get the administrator credentials:
echo Username: root
MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace default mysql-temp -o jsonpath="{.data.mysql-root-password}" | base64 -d)
To connect to your database:
1. Run a pod that you can use as a client:
kubectl run mysql-temp-client --rm --tty -i --restart='Never' --image docker.io/bitnami/mysql:8.0.33-debian-11-r12 --namespace default --env MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD --command -- bash
2. To connect to primary service (read/write):
mysql -h mysql-temp.default.svc.cluster.local -uroot -p"$MYSQL_ROOT_PASSWORD"
ㅁ Pod 기동 확인
$ kubectl get po
NAME READY STATUS RESTARTS AGE
mysql-temp-0 1/1 Running 0 71s
# log 확인
$ kubectl logs pods/mysql-temp-0
Defaulted container "mysql" out of: mysql, volume-permissions (init)
mysql 22:25:16.84
mysql 22:25:16.84 Welcome to the Bitnami mysql container
mysql 22:25:16.84 Subscribe to project updates by watching https://github.com/bitnami/containers
mysql 22:25:16.85 Submit issues and feature requests at https://github.com/bitnami/containers/issues
mysql 22:25:16.85
mysql 22:25:16.85 INFO ==> ** Starting MySQL setup **
mysql 22:25:16.86 INFO ==> Validating settings in MYSQL_*/MARIADB_* env vars
mysql 22:25:16.86 INFO ==> Initializing mysql database
mysql 22:25:16.88 WARN ==> The mysql configuration file '/opt/bitnami/mysql/conf/my.cnf' is not writable. Configurations based on environment variables will not be applied for this file.
mysql 22:25:16.88 INFO ==> Using persisted data
mysql 22:25:16.90 INFO ==> Running mysql_upgrade
mysql 22:25:16.90 INFO ==> Starting mysql in background
find: '/docker-entrypoint-startdb.d/': No such file or directory
mysql 22:25:20.94 INFO ==> Stopping mysql
mysql 22:25:22.99 INFO ==> ** MySQL setup finished! **
mysql 22:25:23.02 INFO ==> ** Starting MySQL **
2023-06-01T22:25:23.249120Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2023-06-01T22:25:23.249135Z 0 [System] [MY-010116] [Server] /opt/bitnami/mysql/bin/mysqld (mysqld 8.0.33) starting as process 1
2023-06-01T22:25:23.251197Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2023-06-01T22:25:23.251201Z 0 [Warning] [MY-013244] [Server] --collation-server: 'utf8mb3_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
2023-06-01T22:25:23.254940Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-06-01T22:25:23.337188Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-06-01T22:25:23.426665Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-06-01T22:25:23.426688Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-06-01T22:25:23.434589Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /tmp/mysqlx.sock
2023-06-01T22:25:23.434660Z 0 [System] [MY-010931] [Server] /opt/bitnami/mysql/bin/mysqld: ready for connections. Version: '8.0.33' socket: '/opt/bitnami/mysql/tmp/mysql.sock' port: 3306 Source distribution.
ㅁ 접속 확인
# 루트 비밀번호 환경변수 선언
$ MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace default mysql-temp -o jsonpath="{.data.mysql-root-password}" | base64 -d)
# Client pod 생성 및 비밀번호 환경변수 전달
$ kubectl run mysql-temp-client --rm --tty -i --restart='Never' \
--image docker.io/bitnami/mysql:8.0.33-debian-11-r12 \
--namespace default --env MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD \
--command -- bash
# mysql 접속
$ mysql -h mysql-temp.default.svc.cluster.local -uroot -p"$MYSQL_ROOT_PASSWORD"
# Error 발생
ERROR 2005 (HY000): Unknown MySQL server host 'mysql-temp.default.svc.cluster.local' (-3)
ㅇ ERROR 2005가 발생하였다.
ㅁ Port-forward로 접속 확인
# 서비스 확인
$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 12d
mysql-temp ClusterIP 10.102.237.215 <none> 3306/TCP 3m22s
mysql-temp-headless ClusterIP None <none> 3306/TCP 3m22s
# port-forward 구문 실행
❯ kubectl port-forward services/mysql-temp 3306
Forwarding from 127.0.0.1:3306 -> 3306
Forwarding from [::1]:3306 -> 3306
Handling connection for 3306
ㅇ 일단 자체 DNS 접속에 문제가 있어서 port-forward를 통해 접속을 확인해 보았다.
ㅇ 로컬에서 port-forward로 접속이 잘 되는 것을 확인할 수 있었다.
ㅁ 함께 보면 좋은 사이트
반응형
'Kubernetes > Helm' 카테고리의 다른 글
[helm] helm으로 redis, grafana 설치과정 (0) | 2023.04.19 |
---|---|
[Helm] Helm으로 jenkins 설치하기 (0) | 2022.10.01 |
[kubernetes] Helm 사용법 (0) | 2022.09.17 |
[kubernetes] Helm이란 (0) | 2022.09.12 |
[kubernetes] helm을 이용한 AWS prometheus설치 후 도메인 연결 (0) | 2022.08.01 |
Comments