Skip to content

Commit

Permalink
[stable/mysqldump] option to run additional shell steps (helm#11100)
Browse files Browse the repository at this point in the history
* add option for additional shell steps to run, fix kc alias in Notes.txt to kubectl

Signed-off-by: Norbert Varzariu <[email protected]>

* bump minor chart version, add example for additionalSteps

Signed-off-by: Norbert Varzariu <[email protected]>
  • Loading branch information
loomsen authored and k8s-ci-robot committed Feb 3, 2019
1 parent fd37371 commit 4c2ca4c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions stable/mysqldump/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v1
appVersion: 2.3.1
appVersion: 2.4.0
description: A Helm chart to help backup MySQL databases using mysqldump
name: mysqldump
version: 2.3.1
version: 2.4.0
keywords:
- mysql
- mysqldump
Expand Down
1 change: 1 addition & 0 deletions stable/mysqldump/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ The following tables lists the configurable parameters of the mysqldump chart an
| schedule | crontab schedule to run on. set as `now` to run as a one time job | "0/5 \* \* \* \*" |
| options | options to pass onto MySQL | "--opt --single-transaction" |
| debug | print some extra debug logs during backup | false |
| additionalSteps | run these extra shell steps after all backup jobs completed | [] |
| successfulJobsHistoryLimit | number of successful jobs to remember | 5 |
| failedJobsHistoryLimit | number of failed jobs to remember | 5 |
| persistentVolumeClaim | existing Persistent Volume Claim to backup to, leave blank to create a new one | |
Expand Down
10 changes: 5 additions & 5 deletions stable/mysqldump/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $ kubectl get pods --selector=job-name={{ template "mysqldump.fullname" . }} --s

To see the logs from the backup job run:

$ kubectl logs `kc get pods --selector=job-name=test-mysqldump --output=jsonpath={.items..metadata.name}`
$ kubectl logs `kubectl get pods --selector=job-name=test-mysqldump --output=jsonpath={.items..metadata.name}`

mysqldump contents can be found in:
{{- if .Values.persistentVolumeClaim }}
Expand All @@ -19,7 +19,7 @@ $ kubectl get persistentvolumeclaim {{ .Values.persistentVolumeClaim }}
{{- if .Values.persistence.enabled }}
$ kubectl get persistentvolumeclaim {{ template "mysqldump.fullname" . }}
{{- else }}
$ kubectl logs `kc get pods --selector=job-name=test-mysqldump --output=jsonpath={.items..metadata.name}`
$ kubectl logs `kubectl get pods --selector=job-name=test-mysqldump --output=jsonpath={.items..metadata.name}`
{{- end -}}
{{- end }}

Expand All @@ -35,8 +35,8 @@ $ kubectl get jobs --selector=cronjob-name={{ template "mysqldump.fullname" . }}

To see the logs from the most recent backup job run:

$ kubectl logs $(kc get pods --selector \
job-name=$(kc get jobs --selector=cronjob-name={{ template "mysqldump.fullname" . }} \
$ kubectl logs $(kubectl get pods --selector \
job-name=$(kubectl get jobs --selector=cronjob-name={{ template "mysqldump.fullname" . }} \
--output=jsonpath='{.items[-1:].metadata.name}') \
--output=jsonpath={.items..metadata.name})

Expand All @@ -47,7 +47,7 @@ $ kubectl get persistentvolumeclaim {{ .Values.persistentVolumeClaim }}
{{- if .Values.persistence.enabled }}
$ kubectl get persistentvolumeclaim {{ template "mysqldump.fullname" . }}
{{- else }}
$ kubectl logs `kc get pods --selector=job-name=test-mysqldump --output=jsonpath={.items..metadata.name}`
$ kubectl logs `kubectl get pods --selector=job-name=test-mysqldump --output=jsonpath={.items..metadata.name}`
{{- end -}}
{{- end }}

Expand Down
6 changes: 6 additions & 0 deletions stable/mysqldump/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ data:
exit 1
fi
{{ if .Values.additionalSteps }}
{{- range .Values.additionalSteps }}
{{ . }}
{{- end }}
{{- end }}
{{ if .Values.debug }}
ls -alh ${BACKUP_DIR}
{{ end }}
Expand Down
8 changes: 8 additions & 0 deletions stable/mysqldump/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ debug: false
successfulJobsHistoryLimit: 5
failedJobsHistoryLimit: 5

# additional steps for mysqldump shell script
# will be inserted after all backup and upload jobs completed successfully.
# Use "${BACKUP_DIR}/${TIMESTAMP}_${MYSQL_DB}.sql.gz" as dump file name.
# see examples
additionalSteps: []
# - gsutil cp "${BACKUP_DIR}/${TIMESTAMP}_${MYSQL_DB}.sql.gz" gs://mybucket/latest.sql.gz
# - echo "latest sql dump updated"

## set persistentVolumeClaim to use a PVC that already exists.
## if set will override any settings under `persistence` otherwise
## if not set and `persistence.enabled` set to true, will create a PVC.
Expand Down

0 comments on commit 4c2ca4c

Please sign in to comment.