Skip to content

Commit

Permalink
feat(backups): improve includedNamespaces and add docs (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
aslafy-z authored Nov 6, 2024
1 parent e9feade commit 8f3b92e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
4 changes: 3 additions & 1 deletion application/templates/backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ spec:
labelSelector:
matchLabels:
app.kubernetes.io/part-of: {{ include "application.name" . }}
{{- range $namespace := .Values.backup.includedNamespaces }}
includedNamespaces:
- {{ .Values.backup.includedNamespace | default ( include "application.namespace" . ) | quote }}
- {{ include "application.tplvalues.render" ( dict "value" $namespace "context" $ ) }}
{{- end }}
defaultVolumesToRestic: {{ .Values.backup.defaultVolumesToRestic }}
snapshotVolumes: {{ .Values.backup.snapshotVolumes }}
storageLocation: {{ .Values.backup.storageLocation | quote }}
Expand Down
24 changes: 24 additions & 0 deletions application/tests/backup_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,30 @@ tests:
path: spec.ttl
value: "1h0m0s"

- it: includes correct includedNamespaces by default
set:
namespaceOverride: base-namespace
backup:
enabled: true
storageLocation: my-storage-location
asserts:
- equal:
path: spec.includedNamespaces
value: [base-namespace]

- it: includes correct includedNamespaces when defined
set:
namespaceOverride: base-namespace
backup:
enabled: true
includedNamespaces:
- my-namespace
storageLocation: my-storage-location
asserts:
- equal:
path: spec.includedNamespaces
value: [my-namespace]

- it: includes includedResources when defined
set:
backup:
Expand Down
6 changes: 5 additions & 1 deletion application/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,6 @@ backup:
namespace:
# -- (object) Additional labels for Backup.
# @section -- Backup Parameters
includedNamespaces:
additionalLabels:
# grafanaDashboard: grafana-operator
# -- (object) Annotations for Backup.
Expand All @@ -1212,6 +1211,11 @@ backup:
# -- (string) How long the Backup should be retained for.
# @section -- Backup Parameters
ttl: "1h0m0s"
# -- (tpl/list) List of namespaces to include objects from.
# @default -- `[ {{ include "application.namespace" $ }} ]`
# @section -- Backup Parameters
includedNamespaces:
- '{{ include "application.namespace" $ }}'
# -- (list) List of resource types to include in the backup.
# @section -- Backup Parameters
includedResources:
Expand Down

0 comments on commit 8f3b92e

Please sign in to comment.