[backups] Added staggered backups

This PS adds staggered backups possibility by adding anti-affinity rules
to backups cronjobs that can be followed across several namespaces to
decrease load on remote backup destination server making sure that at
every moment in time there is only one backup upload is in progress.

Change-Id: If49791f866a73a08fb98fa0e0b4854042d079c66
This commit is contained in:
Sergiy Markin 2023-12-01 22:09:13 +00:00
parent 29f2b616cc
commit 4a95f75b6b
17 changed files with 173 additions and 13 deletions

View File

@ -15,7 +15,7 @@ apiVersion: v1
appVersion: v1.0.0 appVersion: v1.0.0
description: OpenStack-Helm Helm-Toolkit description: OpenStack-Helm Helm-Toolkit
name: helm-toolkit name: helm-toolkit
version: 0.2.56 version: 0.2.57
home: https://docs.openstack.org/openstack-helm home: https://docs.openstack.org/openstack-helm
icon: https://www.openstack.org/themes/openstack/images/project-mascots/OpenStack-Helm/OpenStack_Project_OpenStackHelm_vertical.png icon: https://www.openstack.org/themes/openstack/images/project-mascots/OpenStack-Helm/OpenStack_Project_OpenStackHelm_vertical.png
sources: sources:

View File

@ -243,7 +243,7 @@ send_to_remote_server() {
log ERROR "${DB_NAME}_backup" "Mismatch between the local backup & remote backup MD5 hash values" log ERROR "${DB_NAME}_backup" "Mismatch between the local backup & remote backup MD5 hash values"
return 2 return 2
fi fi
rm -rf ${REMOTE_FILE} rm -f ${REMOTE_FILE}
log INFO "${DB_NAME}_backup" "Created file $FILE in container $CONTAINER_NAME successfully." log INFO "${DB_NAME}_backup" "Created file $FILE in container $CONTAINER_NAME successfully."
return 0 return 0

View File

@ -15,7 +15,7 @@ apiVersion: v1
appVersion: v10.6.14 appVersion: v10.6.14
description: OpenStack-Helm MariaDB backups description: OpenStack-Helm MariaDB backups
name: mariadb-backup name: mariadb-backup
version: 0.0.1 version: 0.0.2
home: https://mariadb.com/kb/en/ home: https://mariadb.com/kb/en/
icon: http://badges.mariadb.org/mariadb-badge-180x60.png icon: http://badges.mariadb.org/mariadb-badge-180x60.png
sources: sources:

View File

@ -56,6 +56,12 @@ spec:
{{ if $envAll.Values.pod.tolerations.mariadb.enabled }} {{ if $envAll.Values.pod.tolerations.mariadb.enabled }}
{{ tuple $envAll "mariadb" | include "helm-toolkit.snippets.kubernetes_tolerations" | indent 10 }} {{ tuple $envAll "mariadb" | include "helm-toolkit.snippets.kubernetes_tolerations" | indent 10 }}
{{ end }} {{ end }}
{{- if $envAll.Values.pod.affinity }}
{{- if $envAll.Values.pod.affinity.mariadb_backup }}
affinity:
{{ index $envAll.Values.pod.affinity "mariadb_backup" | toYaml | indent 12}}
{{- end }}
{{- end }}
nodeSelector: nodeSelector:
{{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value }} {{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value }}
initContainers: initContainers:

View File

@ -0,0 +1,38 @@
---
conf:
backup:
enabled: true
remote_backup:
enabled: false
pod:
labels:
backup:
staggered_backups: enabled
affinity:
mariadb_backup:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: status.phase
operator: NotIn
values:
- Running
- key: staggered-backups
operator: In
values:
- enabled
namespaces:
- openstack
- osh-infra
- ucp
topologyKey: kubernetes.io/os
volume:
backup:
enabled: true
manifests:
pvc_backup: true
job_ks_user: false
cron_job_mariadb_backup: true
secret_backup_restore: true
...

View File

@ -15,7 +15,7 @@ apiVersion: v1
appVersion: v10.6.7 appVersion: v10.6.7
description: OpenStack-Helm MariaDB description: OpenStack-Helm MariaDB
name: mariadb name: mariadb
version: 0.2.35 version: 0.2.36
home: https://mariadb.com/kb/en/ home: https://mariadb.com/kb/en/
icon: http://badges.mariadb.org/mariadb-badge-180x60.png icon: http://badges.mariadb.org/mariadb-badge-180x60.png
sources: sources:

View File

@ -53,9 +53,15 @@ spec:
serviceAccountName: {{ $serviceAccountName }} serviceAccountName: {{ $serviceAccountName }}
restartPolicy: OnFailure restartPolicy: OnFailure
shareProcessNamespace: true shareProcessNamespace: true
{{ if $envAll.Values.pod.tolerations.mariadb.enabled }} {{- if $envAll.Values.pod.tolerations.mariadb.enabled }}
{{ tuple $envAll "mariadb" | include "helm-toolkit.snippets.kubernetes_tolerations" | indent 10 }} {{ tuple $envAll "mariadb" | include "helm-toolkit.snippets.kubernetes_tolerations" | indent 10 }}
{{ end }} {{- end }}
{{- if $envAll.Values.pod.affinity }}
{{- if $envAll.Values.pod.affinity.mariadb_backup }}
affinity:
{{ index $envAll.Values.pod.affinity "mariadb_backup" | toYaml | indent 12}}
{{- end }}
{{- end }}
nodeSelector: nodeSelector:
{{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value }} {{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value }}
initContainers: initContainers:
@ -191,9 +197,6 @@ spec:
mountPath: /tmp/start_verification_server.sh mountPath: /tmp/start_verification_server.sh
readOnly: true readOnly: true
subPath: start_verification_server.sh subPath: start_verification_server.sh
restartPolicy: OnFailure
serviceAccount: {{ $serviceAccountName }}
serviceAccountName: {{ $serviceAccountName }}
volumes: volumes:
- name: pod-tmp - name: pod-tmp
emptyDir: {} emptyDir: {}

View File

@ -0,0 +1,15 @@
---
conf:
backup:
enabled: true
remote_backup:
enabled: false
volume:
backup:
enabled: true
manifests:
pvc_backup: true
job_ks_user: false
cron_job_mariadb_backup: true
secret_backup_restore: true
...

View File

@ -0,0 +1,38 @@
---
conf:
backup:
enabled: true
remote_backup:
enabled: false
pod:
labels:
backup:
staggered_backups: enabled
affinity:
mariadb_backup:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: status.phase
operator: NotIn
values:
- Running
- key: staggered-backups
operator: In
values:
- enabled
namespaces:
- openstack
- osh-infra
- ucp
topologyKey: kubernetes.io/os
volume:
backup:
enabled: true
manifests:
pvc_backup: true
job_ks_user: false
cron_job_mariadb_backup: true
secret_backup_restore: true
...

View File

@ -15,7 +15,7 @@ apiVersion: v1
appVersion: v14.5 appVersion: v14.5
description: OpenStack-Helm PostgreSQL description: OpenStack-Helm PostgreSQL
name: postgresql name: postgresql
version: 0.1.18 version: 0.1.19
home: https://www.postgresql.org home: https://www.postgresql.org
sources: sources:
- https://github.com/postgres/postgres - https://github.com/postgres/postgres

View File

@ -52,6 +52,12 @@ spec:
{{ dict "envAll" $envAll "application" "postgresql_backup" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 10 }} {{ dict "envAll" $envAll "application" "postgresql_backup" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 10 }}
serviceAccountName: {{ $serviceAccountName }} serviceAccountName: {{ $serviceAccountName }}
restartPolicy: OnFailure restartPolicy: OnFailure
{{- if $envAll.Values.pod.affinity }}
{{- if $envAll.Values.pod.affinity.postgresql_backup }}
affinity:
{{ index $envAll.Values.pod.affinity "postgresql_backup" | toYaml | indent 12}}
{{- end }}
{{- end }}
nodeSelector: nodeSelector:
{{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value }} {{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value }}
initContainers: initContainers:
@ -137,9 +143,6 @@ spec:
mountPath: /etc/postgresql/admin_user.conf mountPath: /etc/postgresql/admin_user.conf
subPath: admin_user.conf subPath: admin_user.conf
readOnly: true readOnly: true
restartPolicy: OnFailure
serviceAccount: {{ $serviceAccountName }}
serviceAccountName: {{ $serviceAccountName }}
volumes: volumes:
- name: pod-tmp - name: pod-tmp
emptyDir: {} emptyDir: {}

View File

@ -0,0 +1,15 @@
---
conf:
backup:
enabled: true
remote_backup:
enabled: false
volume:
backup:
enabled: true
manifests:
pvc_backup: true
job_ks_user: false
cron_job_postgresql_backup: true
secret_backup_restore: true
...

View File

@ -0,0 +1,38 @@
---
conf:
backup:
enabled: true
remote_backup:
enabled: false
pod:
labels:
backup:
staggered_backups: enabled
affinity:
postgresql_backup:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: status.phase
operator: NotIn
values:
- Running
- key: staggered-backups
operator: In
values:
- enabled
namespaces:
- openstack
- osh-infra
- ucp
topologyKey: kubernetes.io/os
volume:
backup:
enabled: true
manifests:
pvc_backup: true
job_ks_user: false
cron_job_postgresql_backup: true
secret_backup_restore: true
...

View File

@ -63,4 +63,5 @@ helm-toolkit:
- 0.2.54 Fix dependency resolver to ignore non-existing dependencyKey when dependencyMixinParam is a slice - 0.2.54 Fix dependency resolver to ignore non-existing dependencyKey when dependencyMixinParam is a slice
- 0.2.55 Updated deprecated IngressClass annotation - 0.2.55 Updated deprecated IngressClass annotation
- 0.2.56 Expose S3 credentials from Rook bucket CRD secret - 0.2.56 Expose S3 credentials from Rook bucket CRD secret
- 0.2.57 Safer file removal
... ...

View File

@ -1,4 +1,5 @@
--- ---
mariadb-backup: mariadb-backup:
- 0.0.1 Initial Chart - 0.0.1 Initial Chart
- 0.0.2 Added staggered backups support
... ...

View File

@ -51,4 +51,5 @@ mariadb:
- 0.2.33 Add 2023.1 Ubuntu Focal overrides - 0.2.33 Add 2023.1 Ubuntu Focal overrides
- 0.2.34 Uplift ingress controller image to 1.8.2 - 0.2.34 Uplift ingress controller image to 1.8.2
- 0.2.35 Update apparmor override - 0.2.35 Update apparmor override
- 0.2.36 Added staggered backups support
... ...

View File

@ -19,4 +19,5 @@ postgresql:
- 0.1.16 Added OCI registry authentication - 0.1.16 Added OCI registry authentication
- 0.1.17 Added empty verify_databases_backup_archives() function implementation to match updated backup_databases() function in helm-toolkit - 0.1.17 Added empty verify_databases_backup_archives() function implementation to match updated backup_databases() function in helm-toolkit
- 0.1.18 Updated postgres to 14.5 and replaced deprecated config item wal_keep_segments with wal_keep_size - 0.1.18 Updated postgres to 14.5 and replaced deprecated config item wal_keep_segments with wal_keep_size
- 0.1.19 Added staggered backups support
... ...