Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gitops unige #33

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ drupal7-db-for-astrooda
postfix-container
/private
*config
frontend-container
30 changes: 30 additions & 0 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -68,6 +71,9 @@ spec:
mountPath: /instruments-dir
readOnly: false
{{- end }}
- name: backups
mountPath: /backups
readOnly: true
env:
- name: PASSWORD
valueFrom:
Expand Down Expand Up @@ -151,7 +157,31 @@ 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
- |
set -x
while true; do
mysqldump -h mysql -u astrooda -p$PASSWORD astrooda > /backups/state-snapshot-$(date +%s).sql
sleep 3600;
done


volumeMounts:
- name: backups
mountPath: /backups
readOnly: false
env:
- name: PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.mysql_pw_secret }}
key: mysql-password

{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
14 changes: 13 additions & 1 deletion templates/init-script-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -52,16 +52,22 @@ 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
~/.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
~/.composer/vendor/bin/drush en -y $ENABLED_MMODA_MODULES


chmod -R 777 /var/www/mmoda/sites/default/files

#reset drupal admin
~/.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
Expand All @@ -72,6 +78,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
echo run-sql /backups/state-snapshot.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
Expand Down
27 changes: 21 additions & 6 deletions templates/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,32 @@ spec:
#storageClassName: {{ .Values.storage_class_rwmany }}
#volumeMode: Filesystem

{{ if .Values.extra_instr_dir.enabled | default false }}
# {{ 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 }}

---

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: instruments-dir
name: backups
namespace: staging
spec:
storageClassName: nfs
accessModes:
- ReadWriteMany
- ReadWriteMany
resources:
requests:
storage: 1G
storageClassName: {{ .Values.storage_class_rwmany }}
{{ end }}
storage: 100Gi