Skip to content

Commit

Permalink
Migrate backup upload to use S3 client (#125)
Browse files Browse the repository at this point in the history
* feat(backup): backup is now uploaded using s3 client(s)

* fix: value access in helpers is broken
  • Loading branch information
m90 authored Aug 14, 2023
1 parent 641bba5 commit af3206a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 31 deletions.
2 changes: 1 addition & 1 deletion charts/wbaas-backup/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
appVersion: "1.0"
description: A Helm chart for WbaaS K8s Cronjob Backups
name: wbaas-backup
version: 0.0.6
version: 0.1.0
maintainers:
- name: WMDE
url: https://github.com/wmde
40 changes: 19 additions & 21 deletions charts/wbaas-backup/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@ either will be set to use the `db.load` dict or the `db.dump` dict from the valu
volumeMounts:
- name: "scratch-volume"
mountPath: "/backups/"
{{- if .context.Values.storage.gcs.uploadToBucket }}
- name: "service-account-volume"
mountPath: "/var/run/secret/cloud.google.com"
lifecycle:
postStart:
exec:
command: ["gcsfuse", "--key-file", "/var/run/secret/cloud.google.com/key.json", "{{ .context.Values.storage.gcs.bucketName }}", "/mnt/backup-bucket"]
preStop:
exec:
command: ["fusermount", "-u", /mnt/backup-bucket"]
{{- end }}
securityContext:
privileged: true
capabilities:
Expand All @@ -50,9 +39,23 @@ env:
- name: MYDUMPER_VERBOSE_LEVEL
value: {{ .db.verbosity | quote }}
- name: DO_UPLOAD
value: {{ if .context.Values.storage.gcs.uploadToBucket }}"1"{{else}}"0"{{end}}
- name: GCS_BUCKET_NAME
value: {{ .context.Values.storage.gcs.bucketName | quote }}
value: {{ if .context.Values.storage.uploadToBucket }}"1"{{else}}"0"{{end}}
- name: STORAGE_BUCKET_NAME
value: {{ .context.Values.storage.bucketName | quote }}
- name: STORAGE_SIGNATURE_VERSION
value: {{ .context.Values.storage.signatureVersion | quote }}
- name: STORAGE_ACCESS_KEY
valueFrom:
secretKeyRef:
name: {{ .context.Values.storage.accessKeySecretName | quote }}
key: {{ .context.Values.storage.accessKeySecretKey | quote }}
- name: STORAGE_SECRET_KEY
valueFrom:
secretKeyRef:
name: {{ .context.Values.storage.secretKeySecretName | quote }}
key: {{ .context.Values.storage.secretKeySecretKey | quote }}
- name: STORAGE_ENDPOINT
value: {{ .context.Values.storage.endpoint | quote }}
- name: BACKUP_KEY
valueFrom:
secretKeyRef:
Expand Down Expand Up @@ -81,10 +84,5 @@ volumes:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: {{ .storage.scratchDiskSpace | quote }}
{{- if .storage.gcs.uploadToBucket }}
- name: "service-account-volume"
secret:
secretName: {{ .storage.gcs.serviceAccountSecretName | quote }}
{{- end }}
{{ end }}
storage: {{ . | quote }}
{{ end }}
4 changes: 2 additions & 2 deletions charts/wbaas-backup/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ spec:
resources:
{{- toYaml .Values.resources.job | nindent 14 }}
{{ include "backup.sharedPodConfiguration" ( dict "db" .Values.db.dump "context" $ ) | nindent 12 }}
{{ include "backup.sharedVolumes" ( dict "storage" .Values.storage ) | nindent 10 }}
{{ include "backup.sharedVolumes" .Values.scratchDiskSpace | nindent 10 }}
restartPolicy: Never
backoffLimit: 4
backoffLimit: 4
4 changes: 2 additions & 2 deletions charts/wbaas-backup/templates/restore-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
resources:
{{- toYaml .Values.resources.restorePod | nindent 6 }}
{{ include "backup.sharedPodConfiguration" ( dict "db" .Values.db.load "context" $ ) | nindent 4 }}
{{ include "backup.sharedVolumes" ( dict "storage" .Values.storage ) | nindent 2 }}
{{ include "backup.sharedVolumes" .Values.scratchDiskSpace | nindent 2 }}
restartPolicy: Never

{{- end }}
{{- end }}
15 changes: 10 additions & 5 deletions charts/wbaas-backup/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ job:
backupSecretKey: key
backupSecretName: backup-openssl-key

scratchDiskSpace: 16Gi

storage:
scratchDiskSpace: 16Gi
gcs:
bucketName: nacho-cheese
serviceAccountSecretName: some-gcs-sa
uploadToBucket: true
bucketName: nacho-cheese
uploadToBucket: true
accessKeySecretName: gcs-hmac-key
accessKeySecretKey: access-key
secretKeySecretName: gcs-hmac-key
secretKeySecretKey: secret-key
endpoint: https://storage.googleapis.com
signatureVersion: S3v2

resources:
job:
Expand Down

0 comments on commit af3206a

Please sign in to comment.