From 492810b527b7bc4de18556b373c78c2e93dbe809 Mon Sep 17 00:00:00 2001 From: outductor Date: Sun, 17 Dec 2023 16:50:46 +0900 Subject: [PATCH 1/4] use sts mariadb instead of custom resource --- .../templates/mariadb/mariadb.yaml | 152 ++++++++++++------ 1 file changed, 101 insertions(+), 51 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 b5405e8d6..156780d5e 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 @@ -1,58 +1,108 @@ -apiVersion: mariadb.mmontes.io/v1alpha1 -kind: MariaDB +apiVersion: apps/v1 +kind: StatefulSet metadata: name: mariadb + namespace: seichi-debug-minecraft-on-seichiassist-pr-2115 spec: - initContainers: - - image: mariadb:10.11.6 - env: - - name: DB_PASSWORD + replicas: 1 + updateStrategy: + type: RollingUpdate + revisionHistoryLimit: 10 + selector: + matchLabels: + app.kubernetes.io/instance: mariadb + app.kubernetes.io/name: mariadb + serviceName: mariadb + template: + metadata: + labels: + app.kubernetes.io/instance: mariadb + app.kubernetes.io/name: mariadb + name: mariadb + spec: + containers: + - name: mariadb + image: mariadb:10.11.6 + imagePullPolicy: IfNotPresent + resources: + requests: + cpu: 4000m + memory: 4096Mi + limits: + cpu: 4000m + memory: 8192Mi + env: + - name: MYSQL_TCP_PORT + value: "3306" + - name: MARIADB_ROOT_HOST + value: '%' + - name: MARIADB_USER + value: mcserver + - name: MARIADB_PASSWORD valueFrom: secretKeyRef: + key: mcserver-password name: mariadb-pr-review-password + - name: MARIADB_ALLOW_EMPTY_ROOT_PASSWORD + value: "true" + livenessProbe: + exec: + command: + - bash + - -c + - mariadb -u root -p"${MARIADB_ROOT_PASSWORD}" -e "SELECT 1;" + failureThreshold: 3 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + readinessProbe: + exec: + command: + - bash + - -c + - mariadb -u root -p"${MARIADB_ROOT_PASSWORD}" -e "SELECT 1;" + failureThreshold: 3 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + ports: + - containerPort: 3306 + name: mariadb + protocol: TCP + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - mountPath: /var/lib/mysql + name: storage + - mountPath: /docker-entrypoint-initdb.d + name: sqldump-volume + initContainers: + - name: init-0 + image: mariadb:10.11.6 + imagePullPolicy: IfNotPresent + resources: + requests: + cpu: 4000m + memory: 4096Mi + env: + - name: DB_PASSWORD + valueFrom: + secretKeyRef: key: prod-mariadb-password - volumeMounts: - - name: sqldump-volume - mountPath: /docker-entrypoint-initdb.d - args: - - "sh" - - "-c" - - '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 - key: root-password - - database: seichiassist - username: mcserver - passwordSecretKeyRef: - name: mariadb-pr-review-password - key: mcserver-password - - image: mariadb:10.11.6 - imagePullPolicy: IfNotPresent - - env: - - name: MARIADB_ALLOW_EMPTY_ROOT_PASSWORD - value: "true" - - port: 3306 - - volumeClaimTemplate: - resources: - requests: - storage: 5Gi - storageClassName: synology-iscsi-storage-temp - accessModes: - - ReadWriteOnce - - volumeMounts: - - name: sqldump-volume - mountPath: /docker-entrypoint-initdb.d - - service: - type: ClusterIP - - volumes: - - name: sqldump-volume - emptyDir: {} + name: mariadb-pr-review-password + args: + - sh + - -c + - mysqldump -umcserver -p${DB_PASSWORD} -h192.168.2.186 --databases seichiassist + flyway_managed_schema > /docker-entrypoint-initdb.d/seichiassist.sql + volumeMounts: + - mountPath: /docker-entrypoint-initdb.d + name: sqldump-volume + restartPolicy: Always + volumes: + - name: storage + emptyDir: {} + - name: sqldump-volume + emptyDir: {} From 813b43398ecf5bcf9acfc1a2829bea3867b13f38 Mon Sep 17 00:00:00 2001 From: outductor Date: Sun, 17 Dec 2023 16:52:33 +0900 Subject: [PATCH 2/4] don't specify namespace --- .../templates/mariadb/mariadb.yaml | 1 - 1 file changed, 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 156780d5e..c1492c5ac 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 @@ -2,7 +2,6 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: mariadb - namespace: seichi-debug-minecraft-on-seichiassist-pr-2115 spec: replicas: 1 updateStrategy: From 9c0af3b4f35600bcaae33df9b0ad998b69d9fad4 Mon Sep 17 00:00:00 2001 From: outductor Date: Sun, 17 Dec 2023 17:03:28 +0900 Subject: [PATCH 3/4] update --- .../templates/mariadb/mariadb.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 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 c1492c5ac..28310c104 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 @@ -29,7 +29,6 @@ spec: memory: 4096Mi limits: cpu: 4000m - memory: 8192Mi env: - name: MYSQL_TCP_PORT value: "3306" @@ -102,6 +101,8 @@ spec: restartPolicy: Always volumes: - name: storage - emptyDir: {} + emptyDir: + medium: Memory + sizeLimit: 4Gi - name: sqldump-volume emptyDir: {} From 2d8e6d719f1b746fba004b1fc7cab357f74eab74 Mon Sep 17 00:00:00 2001 From: outductor Date: Sun, 17 Dec 2023 17:05:30 +0900 Subject: [PATCH 4/4] remove default fields --- .../templates/mariadb/mariadb.yaml | 2 -- 1 file changed, 2 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 28310c104..144e1ba0c 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 @@ -69,8 +69,6 @@ spec: - containerPort: 3306 name: mariadb protocol: TCP - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File volumeMounts: - mountPath: /var/lib/mysql name: storage