From 45176c836c06376fb39f72de3f25338798fed533 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Sun, 17 Dec 2023 14:14:33 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20DB=E3=81=AEinitContainer=E3=81=A7?= =?UTF-8?q?=E6=9C=AC=E7=95=AA=E7=92=B0=E5=A2=83=E3=81=AE=E3=83=80=E3=83=B3?= =?UTF-8?q?=E3=83=97=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E5=8F=96?= =?UTF-8?q?=E5=BE=97=E3=81=97=E3=81=A6=E9=81=A9=E7=94=A8=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/mariadb/mariadb.yaml | 33 +++++++++++++++++++ terraform/onp_cluster_secrets.tf | 1 + 2 files changed, 34 insertions(+) diff --git a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/mariadb/mariadb.yaml b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/mariadb/mariadb.yaml index bb77005ad..e4f3ff4f5 100644 --- a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/mariadb/mariadb.yaml +++ b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/mariadb/mariadb.yaml @@ -3,6 +3,23 @@ kind: MariaDB metadata: name: mariadb spec: + initContainers: + - name: sqldump-exporter + image: busybox:1.36.1 + env: + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: mariadb-pr-review-password + key: prod-mariadb-password + volumeMounts: + - name: sqldump-volume + mountPath: /seichiassist.sql + command: + - "sh" + - "-c" + - 'mysqldump -umcserver -p${DB_PASSWORD} -h192.168.2.186 --databases seichiassist > seichiassist.sql' + rootPasswordSecretKeyRef: name: mariadb-pr-review-password key: root-password @@ -22,6 +39,14 @@ spec: port: 3306 + lifecycle: + postStart: + exec: + command: + - "sh" + - "-c" + - 'mysql -uroot -p"${MARIADB_ROOT_PASSWORD}" < seichiassist.sql' + volumeClaimTemplate: resources: requests: @@ -30,5 +55,13 @@ spec: accessModes: - ReadWriteOnce + volumeMounts: + - name: sqldump-volume + mountPath: / + service: type: ClusterIP + + volumes: + - name: sqldump-volume + emptyDir: {} diff --git a/terraform/onp_cluster_secrets.tf b/terraform/onp_cluster_secrets.tf index 0fd963eff..5a2272d24 100644 --- a/terraform/onp_cluster_secrets.tf +++ b/terraform/onp_cluster_secrets.tf @@ -229,6 +229,7 @@ resource "helm_release" "onp_minecraft__pr_review_mariadb_password" { data: root-password: "" mcserver-password: "" + prod-mariadb-password: ${base64encode(var.minecraft__prod_game_db__password)} EOS ] } From f576ee7aa0894ce6332160ec2512855b46a89edf Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Sun, 17 Dec 2023 15:02:47 +0900 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20flyway=E3=81=AE=E3=83=9E=E3=82=A4?= =?UTF-8?q?=E3=82=B0=E3=83=AC=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=B9?= =?UTF-8?q?=E3=82=AD=E3=83=BC=E3=83=9E=E3=81=8Cdump=E3=81=AB=E5=85=A5?= =?UTF-8?q?=E3=81=A3=E3=81=A6=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E3=81=AE?= =?UTF-8?q?=E3=81=A7=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/mariadb/mariadb.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/mariadb/mariadb.yaml b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/mariadb/mariadb.yaml index e4f3ff4f5..f7bd95c72 100644 --- a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/mariadb/mariadb.yaml +++ b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/mariadb/mariadb.yaml @@ -18,7 +18,7 @@ spec: command: - "sh" - "-c" - - 'mysqldump -umcserver -p${DB_PASSWORD} -h192.168.2.186 --databases seichiassist > seichiassist.sql' + - 'mysqldump -umcserver -p${DB_PASSWORD} -h192.168.2.186 --databases seichiassist flyway_managed_schema > seichiassist.sql' rootPasswordSecretKeyRef: name: mariadb-pr-review-password From 4957a489371974798a78baf92b80a795b23ed728 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Sun, 17 Dec 2023 15:42:13 +0900 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20volume=E3=81=AE=E3=83=9E=E3=82=A6?= =?UTF-8?q?=E3=83=B3=E3=83=88=E5=85=88=E3=82=92docker-entrypoint-initdb.d?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/mariadb/mariadb.yaml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/mariadb/mariadb.yaml b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/mariadb/mariadb.yaml index f7bd95c72..7c2743e25 100644 --- a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/mariadb/mariadb.yaml +++ b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/mariadb/mariadb.yaml @@ -14,7 +14,7 @@ spec: key: prod-mariadb-password volumeMounts: - name: sqldump-volume - mountPath: /seichiassist.sql + mountPath: /docker-entrypoint-initdb.d command: - "sh" - "-c" @@ -39,14 +39,6 @@ spec: port: 3306 - lifecycle: - postStart: - exec: - command: - - "sh" - - "-c" - - 'mysql -uroot -p"${MARIADB_ROOT_PASSWORD}" < seichiassist.sql' - volumeClaimTemplate: resources: requests: @@ -57,7 +49,7 @@ spec: volumeMounts: - name: sqldump-volume - mountPath: / + mountPath: /docker-entrypoint-initdb.d service: type: ClusterIP From 3d24f86f919bc100033a097438e6423e7e081f3c Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Sun, 17 Dec 2023 15:54:11 +0900 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20initCotainer=E3=81=AEimage=E3=81=A8d?= =?UTF-8?q?ump=E5=85=88=E3=82=92=E7=9B=B4=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/mariadb/mariadb.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/mariadb/mariadb.yaml b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/mariadb/mariadb.yaml index 7c2743e25..b5405e8d6 100644 --- a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/mariadb/mariadb.yaml +++ b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/mariadb/mariadb.yaml @@ -4,8 +4,7 @@ metadata: name: mariadb spec: initContainers: - - name: sqldump-exporter - image: busybox:1.36.1 + - image: mariadb:10.11.6 env: - name: DB_PASSWORD valueFrom: @@ -15,10 +14,10 @@ spec: volumeMounts: - name: sqldump-volume mountPath: /docker-entrypoint-initdb.d - command: + args: - "sh" - "-c" - - 'mysqldump -umcserver -p${DB_PASSWORD} -h192.168.2.186 --databases seichiassist flyway_managed_schema > seichiassist.sql' + - 'mysqldump -umcserver -p${DB_PASSWORD} -h192.168.2.186 --databases seichiassist flyway_managed_schema > /docker-entrypoint-initdb.d/seichiassist.sql' rootPasswordSecretKeyRef: name: mariadb-pr-review-password