From 7a10655fe589b07a141d01a49eebf411a1278e85 Mon Sep 17 00:00:00 2001 From: Fabio Rauber Date: Tue, 12 Apr 2022 15:20:25 -0300 Subject: [PATCH] Add real velero backup support --- charts/portalmodelo/v0.5.0/questions.yaml | 10 ++++++++-- .../v0.5.0/templates/repozo-configmap.yaml | 6 +++++- .../templates/velero-schedule-monthly.yaml | 19 +++++++++++++++++++ .../templates/velero-schedule-weekdays.yaml | 19 +++++++++++++++++++ .../templates/velero-schedule-weekly.yaml | 19 +++++++++++++++++++ .../templates/zeoserver-deployment.yaml | 10 ++++++++++ charts/portalmodelo/v0.5.0/values.yaml | 2 ++ 7 files changed, 82 insertions(+), 3 deletions(-) diff --git a/charts/portalmodelo/v0.5.0/questions.yaml b/charts/portalmodelo/v0.5.0/questions.yaml index 9a68d44..5607751 100644 --- a/charts/portalmodelo/v0.5.0/questions.yaml +++ b/charts/portalmodelo/v0.5.0/questions.yaml @@ -125,14 +125,14 @@ questions: description: "Espaço em disco disponível para o portal." group: Armazenamento - variable: velero.backup.enabled - default: false + default: true type: boolean label: "Habilitar backup com Velero?" description: "Criar ou não os objetos para backup com o Velero." required: false group: Armazenamento - variable: repozo.enabled - default: true + default: false type: boolean label: "Habilitar backup com Repozo?" description: "Habilitar ou não backup com repozo em volumes NFS." @@ -158,6 +158,12 @@ questions: label: "Número de dias de backups de blobs a guardar." description: "Recomendado utilizar a fórmula 'keep * days_between_zeopack = keep_blob_days'." required: false + - variable: repozo.backupblobs + default: false + type: boolean + label: "Backup Blobs" + description: "Fazer ou não o backup dos blobs com o repozo." + required: false # Configurações Avançadas - variable: portal.timeZone diff --git a/charts/portalmodelo/v0.5.0/templates/repozo-configmap.yaml b/charts/portalmodelo/v0.5.0/templates/repozo-configmap.yaml index 73944b2..8995fbe 100644 --- a/charts/portalmodelo/v0.5.0/templates/repozo-configmap.yaml +++ b/charts/portalmodelo/v0.5.0/templates/repozo-configmap.yaml @@ -1,4 +1,4 @@ -{{- if and .Values.persistence.enabled .Values.repozo.enabled }} +{{- if and .Values.persistence.enabled (or .Values.repozo.enabled .Values.velero.backup.enabled )}} apiVersion: v1 kind: ConfigMap metadata: @@ -51,7 +51,11 @@ data: verbose=False, gzip=True, only_blobs=False, + {{- if .Values.repozo.backupblobs }} backup_blobs=True, + {{- else }} + backup_blobs=False, + {{- end }} use_rsync=True, gzip_blob=False, pre_command='', diff --git a/charts/portalmodelo/v0.5.0/templates/velero-schedule-monthly.yaml b/charts/portalmodelo/v0.5.0/templates/velero-schedule-monthly.yaml index e37a400..efe2b20 100644 --- a/charts/portalmodelo/v0.5.0/templates/velero-schedule-monthly.yaml +++ b/charts/portalmodelo/v0.5.0/templates/velero-schedule-monthly.yaml @@ -17,5 +17,24 @@ spec: snapshotVolumes: {{ .Values.velero.backup.snapshotVolumes }} # every weekday backup is good for the next year (365 days) ttl: 8760h0m0s + defaultVolumesToRestic: {{ .Values.velero.backup.defaultVolumesToRestic }} + hooks: + resources: + - name: repozo + includedResources: + - pods + labelSelector: + matchLabels: + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: portalmodelo + app.kubernetes.io/component: zeoserver + pre: + - exec: + command: + - "/bin/bash" + - "-c" + - "/plone/Python-2.7/bin/python /plone/instance/bin/backup" + timeout: 3600s + onError: Continue useOwnerReferencesInBackup: false {{- end }} \ No newline at end of file diff --git a/charts/portalmodelo/v0.5.0/templates/velero-schedule-weekdays.yaml b/charts/portalmodelo/v0.5.0/templates/velero-schedule-weekdays.yaml index 43171f4..2816c3a 100644 --- a/charts/portalmodelo/v0.5.0/templates/velero-schedule-weekdays.yaml +++ b/charts/portalmodelo/v0.5.0/templates/velero-schedule-weekdays.yaml @@ -17,5 +17,24 @@ spec: snapshotVolumes: {{ .Values.velero.backup.snapshotVolumes }} # every weekday backup is good for the next week (7 days) ttl: 168h0m0s + defaultVolumesToRestic: {{ .Values.velero.backup.defaultVolumesToRestic }} + hooks: + resources: + - name: repozo + includedResources: + - pods + labelSelector: + matchLabels: + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: portalmodelo + app.kubernetes.io/component: zeoserver + pre: + - exec: + command: + - "/bin/bash" + - "-c" + - "/plone/Python-2.7/bin/python /plone/instance/bin/backup" + timeout: 3600s + onError: Continue useOwnerReferencesInBackup: false {{- end }} \ No newline at end of file diff --git a/charts/portalmodelo/v0.5.0/templates/velero-schedule-weekly.yaml b/charts/portalmodelo/v0.5.0/templates/velero-schedule-weekly.yaml index 3c6bbe1..6ba21ae 100644 --- a/charts/portalmodelo/v0.5.0/templates/velero-schedule-weekly.yaml +++ b/charts/portalmodelo/v0.5.0/templates/velero-schedule-weekly.yaml @@ -17,5 +17,24 @@ spec: snapshotVolumes: {{ .Values.velero.backup.snapshotVolumes }} # every sunday backup is good for 30 days (aprox. 1 month) ttl: 744h0m0s + defaultVolumesToRestic: {{ .Values.velero.backup.defaultVolumesToRestic }} + hooks: + resources: + - name: repozo + includedResources: + - pods + labelSelector: + matchLabels: + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: portalmodelo + app.kubernetes.io/component: zeoserver + pre: + - exec: + command: + - "/bin/bash" + - "-c" + - "/plone/Python-2.7/bin/python /plone/instance/bin/backup" + timeout: 3600s + onError: Continue useOwnerReferencesInBackup: false {{- end }} \ No newline at end of file diff --git a/charts/portalmodelo/v0.5.0/templates/zeoserver-deployment.yaml b/charts/portalmodelo/v0.5.0/templates/zeoserver-deployment.yaml index 2ce452b..18d4373 100644 --- a/charts/portalmodelo/v0.5.0/templates/zeoserver-deployment.yaml +++ b/charts/portalmodelo/v0.5.0/templates/zeoserver-deployment.yaml @@ -79,6 +79,11 @@ spec: volumeMounts: - mountPath: /data name: data + {{- if .Values.velero.backup.enabled }} + - mountPath: /plone/instance/bin/backup + subPath: backup + name: backupscript + {{- end }} livenessProbe: tcpSocket: port: 8100 @@ -106,6 +111,11 @@ spec: {{- else }} emptyDir: {} {{- end }} + {{- if .Values.velero.backup.enabled }} + - name: backupscript + configMap: + name: {{ include "portalmodelo.fullname" . }}-backupscript + {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/charts/portalmodelo/v0.5.0/values.yaml b/charts/portalmodelo/v0.5.0/values.yaml index fcd3198..748aede 100644 --- a/charts/portalmodelo/v0.5.0/values.yaml +++ b/charts/portalmodelo/v0.5.0/values.yaml @@ -25,6 +25,7 @@ velero: backup: enabled: false snapshotVolumes: true + defaultVolumesToRestic: true # cert-manager objects are usually blocked during backup excludedResources: - certificates.cert-manager.io @@ -58,6 +59,7 @@ repozo: storageClass: nfs-backup keep: 1 keepblobdays: 30 + backupblobs: true podAnnotations: {}