'데이터 엔지니어'로 성장하기

정리하는 걸 좋아하고, 남이 읽으면 더 좋아함

Storage/mariadb

Kubernetes)Mariadb 설치_helm

MightyTedKim 2022. 2. 23. 09:32
728x90
반응형

 

 

결과

$ k get all -n mariadb
NAME                               READY   STATUS    RESTARTS   AGE
pod/mariadb-20220222-primary-0     1/1     Running   0          114s
pod/mariadb-20220222-secondary-0   1/1     Running   0          114s

NAME                                 TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
service/mariadb-20220222-primary     NodePort   10.102.244.92   <none>        3306:30009/TCP   114s
service/mariadb-20220222-secondary   NodePort   10.106.51.198   <none>        3306:30008/TCP   114s

NAME                                          READY   AGE
statefulset.apps/mariadb-20220222-primary     1/1     114s

설치

$ helm search repo mariadb
NAME            CHART VERSION   APP VERSION     DESCRIPTION
hgkim/mariadb  10.1.0          10.5.13         Fast, reliable, scalable, and easy to use open-...

$helm pull hgkim/mariadb --insecure-skip-tls-verify

$ ll
-rw-r--r-- 1 bigdata bigdata 37303 Feb 22 16:35 mariadb-10.1.0.tgz

$ tar -xvzf ./mariadb-10.1.0.tgz
$ cd mariadb

$ helm install mariadb-20220222 hgkim/mariadb -n mariadb -f values.yaml --debug --insecure-skip-tls-verify

$ helm list -n mariadb
NAME                    NAMESPACE       REVISION        UPDATED                                 STATUS          CHART           APP VERSION
mariadb-20220222        mariadb         1               2022-02-22 16:50:47.130794417 +0900 KST deployed        mariadb-10.1.0  10.5.13

$ k get all -n mariadb
NAME                               READY   STATUS    RESTARTS   AGE
pod/mariadb-20220222-primary-0     0/1     Running   0          36s
pod/mariadb-20220222-secondary-0   0/1     Running   0          36s

NAME                                 TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
service/mariadb-20220222-primary     NodePort   10.102.244.92   <none>        3306:30009/TCP   36s
service/mariadb-20220222-secondary   NodePort   10.106.51.198   <none>        3306:30008/TCP   36s

NAME                                          READY   AGE
statefulset.apps/mariadb-20220222-primary     0/1     36s
statefulset.apps/mariadb-20220222-secondary   0/1     36s
 

특이사항

init

$ k exec -it pod/mariadb-20220222-primary-0 -n mariadb -- /bin/sh

$ mysql -uroot -pmysql

MariaDB [mysql]>  create database db_pqe
MariaDB [mysql]>  CREATE USER 'hgkim'@'%' IDENTIFIED BY 'dpszhdk';
MariaDB [mysql]> select host, user, Password  from user;
+-----------+-------------+-------------------------------------------+
| Host      | User        | Password                                  |
+-----------+-------------+-------------------------------------------+
| localhost | mariadb.sys |                                           |
| %         | root        | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
| %         | replicator  | *F824DC8B536AEAAFEDE113A686D102B2DA2B1BEA |
| %         | hgkim      | *C6B9B7B84E7D9098DE633A46F23D4E429046DDE4 |
+-----------+-------------+-------------------------------------------+

MariaDB [db_pqe]> use db_pqe;
Database changed

MariaDB [db_pqe]> show variables like '%time_zone%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | UTC    |
| time_zone        | SYSTEM |
+------------------+--------+
2 rows in set (0.001 sec)

MariaDB [db_pqe]> SELECT NOW();
+---------------------+
| NOW()               |
+---------------------+
| 2022-02-22 08:12:16 |
+---------------------+
 

timezone 변경, extraEnv로 적용

참고: https://stackoverflow.com/questions/61751986/timezone-in-requirements-yaml-to-add-dependency-to-a-helm-chart

values.yaml

  #extraEnvVars: []
  extraEnvVars:
    - name: TZ
      value: "Asia/Seoul" #"UTC" 

  #extraEnvVars: []
  extraEnvVars:
    - name: TZ
      value: "Asia/Seoul" #"UTC" 

업데이트

$ helm  upgrade --install mariadb-20220222 hgkim/mariadb -n mariadb -f values.yaml --debug --insecure-skip-tls-verify --set auth.replicationPassword=mysql
history.go:56: [debug] getting history for release mariadb-20220222
upgrade.go:139: [debug] preparing upgrade for mariadb-20220222
upgrade.go:147: [debug] performing update for mariadb-20220222
upgrade.go:319: [debug] creating upgraded release for mariadb-20220222
client.go:218: [debug] checking 8 resources for changes
client.go:501: [debug] Looks like there are no changes for ServiceAccount "mariadb-20220222" 
client.go:501: [debug] Looks like there are no changes for ConfigMap "mariadb-20220222-primary" 
client.go:501: [debug] Looks like there are no changes for ConfigMap "mariadb-20220222-secondary" 
client.go:501: [debug] Looks like there are no changes for Service "mariadb-20220222-primary" 
client.go:501: [debug] Looks like there are no changes for Service "mariadb-20220222-secondary" 
upgrade.go:154: [debug] updating status for upgraded release for mariadb-20220222
Release "mariadb-20220222" has been upgraded. Happy Helming!
NAME: mariadb-20220222
LAST DEPLOYED: Tue Feb 22 17:54:03 2022
NAMESPACE: mariadb
STATUS: deployed
REVISION: 5
TEST SUITE: None
USER-SUPPLIED VALUES:
architecture: replication
primary:
  extraEnvVars:
  - name: TZ
    value: Asia/Seoul
secondary:
  extraEnvVars:
  - name: TZ
    value: Asia/Seoul

COMPUTED VALUES:
architecture: replication
  extraEnvVars:
  - name: TZ
    value: Asia/Seoul
  extraEnvVars:
  - name: TZ
    value: Asia/Seoul

      containers:
        - name: mariadb
          env:
            - name: TZ
              value: Asia/Seoul

# 여러 군데에 적용된 것을 볼 수 있음

$ k get all -n mariadb
NAME                               READY   STATUS    RESTARTS   AGE
pod/mariadb-20220222-primary-0     1/1     Running   0          52s
pod/mariadb-20220222-secondary-0   1/1     Running   0          52s

$ k exec -it pod/mariadb-20220222-primary-0 -n mariadb -n mariadb -- /bin/sh

MariaDB [db_pqe]> select now();
+---------------------+
| now()               |
+---------------------+
| 2022-02-22 18:01:45 |
+---------------------+
1 row in set (0.000 sec)

MariaDB [db_pqe]> show variables like '%time_zone%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | KST    |
| time_zone        | SYSTEM |
+------------------+--------+
2 rows in set (0.001 sec)

MariaDB [db_pqe]> SELECT @@GLOBAL.time_zone, @@SESSION.time_zone, @@system_time_zone;
+--------------------+---------------------+--------------------+
| @@GLOBAL.time_zone | @@SESSION.time_zone | @@system_time_zone |
+--------------------+---------------------+--------------------+
| SYSTEM             | SYSTEM              | KST                |
+--------------------+---------------------+--------------------+

 

timzone 변경 방법은 아래에

https://mightytedkim.tistory.com/59

728x90
반응형