-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The old email cronjob template was moved from cronjob.yaml to cronjob-email.yaml and the new db cronjob template is named cronjob-backup.yaml. This migrates the old manually created prod db backup cronjob to one that's managed by the chart. The old cronjob was no longer working ever since we started using replication since the db pod names were changed. New config values were added for this feature under 'cronjob.backup'. The most important is the ones specifying the nfs mount where we store the backups, 'cronjob.backup.nfs.path' and 'cronjob.backup.nfs.server' must be set properly in the env value files.
- Loading branch information
1 parent
8234c01
commit 64e3d58
Showing
4 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |
2 changes: 1 addition & 1 deletion
2
ipeer/templates/cronjob.yaml → ipeer/templates/cronjob-email.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters