From 991b1bda30fcda5b811b36098c787c0f7efa2d0b Mon Sep 17 00:00:00 2001 From: Volodymyr Savchenko Date: Wed, 14 Feb 2024 22:19:17 +0100 Subject: [PATCH 01/12] track errors --- templates/init-script-cm.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/init-script-cm.yaml b/templates/init-script-cm.yaml index c90556b..443f23d 100644 --- a/templates/init-script-cm.yaml +++ b/templates/init-script-cm.yaml @@ -6,7 +6,7 @@ metadata: data: init-script.sh: | #!/bin/bash - set -x + set -xe # Install jq if not available JQ_URL=https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 JQ_BIN=/usr/local/bin/jq From acdddb0a12acdef6ee5fcf1e194551d0dfa358a3 Mon Sep 17 00:00:00 2001 From: Volodymyr Savchenko Date: Wed, 14 Feb 2024 22:34:08 +0100 Subject: [PATCH 02/12] track errors --- templates/init-script-cm.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/init-script-cm.yaml b/templates/init-script-cm.yaml index 443f23d..e696018 100644 --- a/templates/init-script-cm.yaml +++ b/templates/init-script-cm.yaml @@ -62,6 +62,7 @@ data: chmod -R 777 /var/www/mmoda/sites/default/files #reset drupal admin + ~/.composer/vendor/bin/drush user-cancel admin || true ~/.composer/vendor/bin/drush user-create admin --password=$DRUPAL_PW ~/.composer/vendor/bin/drush user-add-role "administrator" admin ~/.composer/vendor/bin/drush upwd --password=$DRUPAL_PW admin From 4d87484c342dd48e0fe4765a042ead2e74fe891a Mon Sep 17 00:00:00 2001 From: Volodymyr Savchenko Date: Wed, 14 Feb 2024 22:39:41 +0100 Subject: [PATCH 03/12] track errors --- templates/init-script-cm.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/init-script-cm.yaml b/templates/init-script-cm.yaml index e696018..2f7186b 100644 --- a/templates/init-script-cm.yaml +++ b/templates/init-script-cm.yaml @@ -62,7 +62,7 @@ data: chmod -R 777 /var/www/mmoda/sites/default/files #reset drupal admin - ~/.composer/vendor/bin/drush user-cancel admin || true + ~/.composer/vendor/bin/drush user-cancel admin -y || true ~/.composer/vendor/bin/drush user-create admin --password=$DRUPAL_PW ~/.composer/vendor/bin/drush user-add-role "administrator" admin ~/.composer/vendor/bin/drush upwd --password=$DRUPAL_PW admin From 14f34fb2e8629de5857c05c0c6e00b3f79574e0c Mon Sep 17 00:00:00 2001 From: Volodymyr Savchenko Date: Tue, 19 Mar 2024 10:11:01 +0100 Subject: [PATCH 04/12] backups and restore --- templates/deployment.yaml | 29 +++++++++++++++++++++++++++++ templates/init-script-cm.yaml | 6 ++++++ templates/pvc.yaml | 17 ++++++++++++++++- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 3f43f0a..deae19e 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -37,6 +37,9 @@ spec: configMap: name: frontend-init-script defaultMode: 0555 + - name: backups + persistentVolumeClaim: + claimName: backups - name: patched-files emptyDir: {} {{- if .Values.extra_instr_dir.enabled }} @@ -68,6 +71,9 @@ spec: mountPath: /instruments-dir readOnly: false {{- end }} + - name: backups + mountPath: /backups + readOnly: true env: - name: PASSWORD valueFrom: @@ -151,7 +157,30 @@ spec: mountPath: /var/www/mmoda/sites/all/modules/mmoda/instruments readOnly: false {{- end }} + - name: backup + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: + - bash + - -c + - | + while true; do + mysql -h mysql -u astrooda -p$PASSWORD astrooda > /backups/state-snapshot-$(date +%s).sql + sleep 3600; + done + + volumeMounts: + - name: backups + mountPath: /backups + readOnly: true + env: + - name: PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.mysql_pw_secret }} + key: mysql-password + {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/templates/init-script-cm.yaml b/templates/init-script-cm.yaml index 2f7186b..c288a82 100644 --- a/templates/init-script-cm.yaml +++ b/templates/init-script-cm.yaml @@ -73,6 +73,12 @@ data: run-sql <(echo "use astrooda; update variable set value='s:30:"vendor/swiftmailer/swiftmailer";' where name='swiftmailer_path';") + if [ -f /backups/state-snapshot.sql ]; then + < /backups/state-snapshot.sql run-sql + else + echo "No state-snapshot.sql found in /backups" + fi + ~/.composer/vendor/bin/drush cc -y all #cp -rfv /var/www/mmoda/sites/all/modules/rules /patched-files/rules diff --git a/templates/pvc.yaml b/templates/pvc.yaml index 00bf4c8..c25c3a3 100644 --- a/templates/pvc.yaml +++ b/templates/pvc.yaml @@ -66,4 +66,19 @@ spec: requests: storage: 1G storageClassName: {{ .Values.storage_class_rwmany }} -{{ end }} \ No newline at end of file +{{ end }} + +--- + +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: backups + namespace: staging +spec: + storageClassName: nfs + accessModes: + - ReadWriteMany + resources: + requests: + storage: 100Gi From 1dea9ab9bbb158eb73a5bc9f2f49d6cf0d9c161a Mon Sep 17 00:00:00 2001 From: Volodymyr Savchenko Date: Tue, 19 Mar 2024 20:50:08 +0100 Subject: [PATCH 05/12] backups and restore --- templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/deployment.yaml b/templates/deployment.yaml index deae19e..c92f7a0 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -173,7 +173,7 @@ spec: volumeMounts: - name: backups mountPath: /backups - readOnly: true + readOnly: false env: - name: PASSWORD valueFrom: From 3f9049875306f47a0f880c7e594af0fefdc73ebe Mon Sep 17 00:00:00 2001 From: Volodymyr Savchenko Date: Tue, 19 Mar 2024 20:55:00 +0100 Subject: [PATCH 06/12] backups and restore --- templates/deployment.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/deployment.yaml b/templates/deployment.yaml index c92f7a0..b3cd363 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -164,6 +164,7 @@ spec: - bash - -c - | + set -x while true; do mysql -h mysql -u astrooda -p$PASSWORD astrooda > /backups/state-snapshot-$(date +%s).sql sleep 3600; From c0d1985924084bd47732dc4dd0c7688d1f5cb1a4 Mon Sep 17 00:00:00 2001 From: Volodymyr Savchenko Date: Tue, 19 Mar 2024 20:58:09 +0100 Subject: [PATCH 07/12] backups and restore --- templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/deployment.yaml b/templates/deployment.yaml index b3cd363..8ec41af 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -166,7 +166,7 @@ spec: - | set -x while true; do - mysql -h mysql -u astrooda -p$PASSWORD astrooda > /backups/state-snapshot-$(date +%s).sql + mysqldump -h mysql -u astrooda -p$PASSWORD astrooda > /backups/state-snapshot-$(date +%s).sql sleep 3600; done From 204e5a98d21e6918f2b8ee33d1e747e5984f0eb8 Mon Sep 17 00:00:00 2001 From: Volodymyr Savchenko Date: Tue, 19 Mar 2024 21:01:35 +0100 Subject: [PATCH 08/12] backups and restore --- templates/init-script-cm.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/init-script-cm.yaml b/templates/init-script-cm.yaml index c288a82..6b23b8b 100644 --- a/templates/init-script-cm.yaml +++ b/templates/init-script-cm.yaml @@ -74,7 +74,7 @@ data: run-sql <(echo "use astrooda; update variable set value='s:30:"vendor/swiftmailer/swiftmailer";' where name='swiftmailer_path';") if [ -f /backups/state-snapshot.sql ]; then - < /backups/state-snapshot.sql run-sql + run-sql /backups/state-snapshot.sql else echo "No state-snapshot.sql found in /backups" fi From 7aa934648c6d902df6c013c770360cd10da3d4f7 Mon Sep 17 00:00:00 2001 From: Volodymyr Savchenko Date: Tue, 19 Mar 2024 21:10:22 +0100 Subject: [PATCH 09/12] backups and restore --- templates/init-script-cm.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/init-script-cm.yaml b/templates/init-script-cm.yaml index 6b23b8b..7375471 100644 --- a/templates/init-script-cm.yaml +++ b/templates/init-script-cm.yaml @@ -74,7 +74,7 @@ data: run-sql <(echo "use astrooda; update variable set value='s:30:"vendor/swiftmailer/swiftmailer";' where name='swiftmailer_path';") if [ -f /backups/state-snapshot.sql ]; then - run-sql /backups/state-snapshot.sql + echo run-sql /backups/state-snapshot.sql else echo "No state-snapshot.sql found in /backups" fi From 0d045f09248939831638b7ce7de972ceedea47e4 Mon Sep 17 00:00:00 2001 From: Volodymyr Savchenko Date: Tue, 19 Mar 2024 22:02:02 +0100 Subject: [PATCH 10/12] backups and restore --- templates/pvc.yaml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/templates/pvc.yaml b/templates/pvc.yaml index c25c3a3..fcca7bc 100644 --- a/templates/pvc.yaml +++ b/templates/pvc.yaml @@ -53,20 +53,20 @@ spec: #storageClassName: {{ .Values.storage_class_rwmany }} #volumeMode: Filesystem -{{ if .Values.extra_instr_dir.enabled | default false }} ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: instruments-dir -spec: - accessModes: - - ReadWriteMany - resources: - requests: - storage: 1G - storageClassName: {{ .Values.storage_class_rwmany }} -{{ end }} +# {{ if .Values.extra_instr_dir.enabled | default false }} +# --- +# apiVersion: v1 +# kind: PersistentVolumeClaim +# metadata: +# name: instruments-dir +# spec: +# accessModes: +# - ReadWriteMany +# resources: +# requests: +# storage: 1G +# storageClassName: {{ .Values.storage_class_rwmany }} +# {{ end }} --- From 2173503a9b96dc2bd1f00038766f670926276730 Mon Sep 17 00:00:00 2001 From: Volodymyr Savchenko Date: Thu, 4 Jul 2024 18:30:18 +0200 Subject: [PATCH 11/12] reinstall mmoda integral --- templates/init-script-cm.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/init-script-cm.yaml b/templates/init-script-cm.yaml index 7375471..a3fd7bd 100644 --- a/templates/init-script-cm.yaml +++ b/templates/init-script-cm.yaml @@ -52,10 +52,13 @@ data: # Drush reinstall all mmoda modules ALL_MMODA_MODULES=`~/.composer/vendor/bin/drush pm-list --type=module --format=json | jq -r '[ keys[] | select(startswith("mmoda_")) ] | join(",")'` + ~/.composer/vendor/bin/drush dis -y mmoda_integral ~/.composer/vendor/bin/drush dis -y mmoda ~/.composer/vendor/bin/drush pm-uninstall -y $ALL_MMODA_MODULES + ~/.composer/vendor/bin/drush pm-uninstall -y mmoda_integral ~/.composer/vendor/bin/drush pm-uninstall -y mmoda ~/.composer/vendor/bin/drush en -y mmoda + ~/.composer/vendor/bin/drush en -y mmoda_integral ~/.composer/vendor/bin/drush en -y $MMODA_MODULES From c77a9cb13aad666e1e4f0303a4d80dbb2e95ad39 Mon Sep 17 00:00:00 2001 From: Volodymyr Savchenko Date: Mon, 30 Dec 2024 14:10:51 +0100 Subject: [PATCH 12/12] enable more modules --- .helmignore | 1 + templates/init-script-cm.yaml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.helmignore b/.helmignore index fc2d1f0..94388e2 100644 --- a/.helmignore +++ b/.helmignore @@ -5,3 +5,4 @@ drupal7-db-for-astrooda postfix-container /private *config +frontend-container diff --git a/templates/init-script-cm.yaml b/templates/init-script-cm.yaml index a3fd7bd..78ebcd1 100644 --- a/templates/init-script-cm.yaml +++ b/templates/init-script-cm.yaml @@ -52,6 +52,7 @@ data: # Drush reinstall all mmoda modules ALL_MMODA_MODULES=`~/.composer/vendor/bin/drush pm-list --type=module --format=json | jq -r '[ keys[] | select(startswith("mmoda_")) ] | join(",")'` + ENABLED_MMODA_MODULES=`~/.composer/vendor/bin/drush pm-list --type=module --status=enabled --format=json | jq -r '[ keys[] | select(startswith("mmoda_")) ] | join(",")'` ~/.composer/vendor/bin/drush dis -y mmoda_integral ~/.composer/vendor/bin/drush dis -y mmoda ~/.composer/vendor/bin/drush pm-uninstall -y $ALL_MMODA_MODULES @@ -60,6 +61,7 @@ data: ~/.composer/vendor/bin/drush en -y mmoda ~/.composer/vendor/bin/drush en -y mmoda_integral ~/.composer/vendor/bin/drush en -y $MMODA_MODULES + ~/.composer/vendor/bin/drush en -y $ENABLED_MMODA_MODULES chmod -R 777 /var/www/mmoda/sites/default/files