diff --git a/ipeer/Chart.yaml b/ipeer/Chart.yaml index 33b7276..d4c7f02 100644 --- a/ipeer/Chart.yaml +++ b/ipeer/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.9 +version: 0.1.11 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/ipeer/templates/cronjob-backup.yaml b/ipeer/templates/cronjob-backup.yaml new file mode 100644 index 0000000..df7a65b --- /dev/null +++ b/ipeer/templates/cronjob-backup.yaml @@ -0,0 +1,54 @@ +{{- if .Values.cronjob.backup.enabled }} +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ include "ipeer.fullname" . }}-backup-cronjob +spec: + schedule: {{ .Values.cronjob.backup.schedule | quote }} + jobTemplate: + spec: + template: + spec: + containers: + - name: {{ include "ipeer.fullname" . }}-backup-cronjob + image: "{{ .Values.db.image.repository }}:{{ .Values.db.image.tag }}" + args: + - /bin/sh + - -c + - | + set -e + echo "[$(date)] - Starts backing up ipeer database!" + CURRENT_YEAR=$(date +%Y) + MYSQLDMP_FILE=/db_archives/$CURRENT_YEAR/$IPEER_ENV_NAME-db-$(date +%F_%T).sql.gz + mkdir -p /db_archives/$CURRENT_YEAR + mysqldump -u"$IPEER_DB_USER" -p"$IPEER_DB_PASSWORD" -h"$IPEER_DB_HOST" ipeer --single-transaction --quick | gzip > $MYSQLDMP_FILE + zgrep "Dump completed" $MYSQLDMP_FILE + env: + - name: IPEER_ENV_NAME + value: {{ include "ipeer.fullname" . }} + - name: IPEER_DB_HOST + value: {{ template "ipeer.db.fullname" . }} + - name: IPEER_DB_PORT + value: {{ .Values.db.service.port | quote }} + - name: IPEER_DB_USER + value: {{ .Values.db.auth.username | quote }} + - name: IPEER_DB_PASSWORD + valueFrom: + secretKeyRef: + {{- if .Values.db.disableExternal }} + name: {{ template "ipeer.db.secretName" . }} + key: mariadb-password + {{- else }} + name: {{ template "ipeer.fullname" . }} + key: db_password + {{- end }} + volumeMounts: + - mountPath: /db_archives + name: nfs-volume + restartPolicy: Never + volumes: + - name: nfs-volume + nfs: + path: {{ .Values.cronjob.backup.nfs.path | quote }} + server: {{ .Values.cronjob.backup.nfs.server | quote }} +{{- end }} diff --git a/ipeer/templates/cronjob.yaml b/ipeer/templates/cronjob-email.yaml similarity index 98% rename from ipeer/templates/cronjob.yaml rename to ipeer/templates/cronjob-email.yaml index 5970d06..eaf26f7 100644 --- a/ipeer/templates/cronjob.yaml +++ b/ipeer/templates/cronjob-email.yaml @@ -1,4 +1,4 @@ -{{- if .Values.cronjob.enabled }} +{{- if .Values.cronjob.email.enabled }} apiVersion: batch/v1 kind: CronJob metadata: diff --git a/ipeer/values.yaml b/ipeer/values.yaml index 6d65949..40cf3c0 100644 --- a/ipeer/values.yaml +++ b/ipeer/values.yaml @@ -25,7 +25,14 @@ worker: enabled: false cronjob: - enabled: true + email: + enabled: true + backup: + enabled: false + schedule: "00 09 * * *" + nfs: + path: 'REPLACEME' + server: 'REPLACEME' imagePullSecrets: [] nameOverride: ""