From 52e7e38dec4322c9f1632c33014bebb1c2024ed3 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Fri, 19 Jun 2026 22:27:58 +0300 Subject: [PATCH 01/43] feat( cluster ): Barman Cloud CNPG-I plugin support Signed-off-by: Itay Grudev --- charts/cluster/README.md | 7 +- charts/cluster/templates/NOTES.txt | 2 +- charts/cluster/templates/_backup.tpl | 2 +- charts/cluster/templates/_bootstrap.tpl | 2 + .../cluster/templates/_external_clusters.tpl | 13 +++ charts/cluster/templates/_helpers.tpl | 86 +++++++++++++++++++ .../cluster/templates/backup-objectstore.yaml | 36 ++++++++ charts/cluster/templates/ca-bundle.yaml | 2 + charts/cluster/templates/cluster.yaml | 20 +++++ .../templates/recovery-objectstore.yaml | 23 +++++ .../cluster/templates/scheduled-backups.yaml | 4 + charts/cluster/values.schema.json | 20 ++++- charts/cluster/values.yaml | 28 +++++- 13 files changed, 238 insertions(+), 7 deletions(-) create mode 100644 charts/cluster/templates/backup-objectstore.yaml create mode 100644 charts/cluster/templates/recovery-objectstore.yaml diff --git a/charts/cluster/README.md b/charts/cluster/README.md index 203f8c146d..5590f7ab1e 100644 --- a/charts/cluster/README.md +++ b/charts/cluster/README.md @@ -136,6 +136,7 @@ Kubernetes: `>=1.29.0-0` | backups.google.bucket | string | `""` | | | backups.google.gkeEnvironment | bool | `false` | | | backups.google.path | string | `"/"` | | +| backups.method | string | `"barmanObjectStore"` | One of `barmanObjectStore` (default) or `plugin` | | backups.provider | string | `"s3"` | One of `s3`, `azure` or `google` | | backups.retentionPolicy | string | `"30d"` | Retention policy for backups | | backups.s3.accessKey | string | `""` | | @@ -145,7 +146,7 @@ Kubernetes: `>=1.29.0-0` | backups.s3.region | string | `""` | | | backups.s3.secretKey | string | `""` | | | backups.scheduledBackups[0].backupOwnerReference | string | `"self"` | Backup owner reference | -| backups.scheduledBackups[0].method | string | `"barmanObjectStore"` | Backup method, can be `barmanObjectStore` (default) or `volumeSnapshot` | +| backups.scheduledBackups[0].method | string | `"barmanObjectStore"` | Backup method, can be `barmanObjectStore` (default), `volumeSnapshot` or `plugin`. | | backups.scheduledBackups[0].name | string | `"daily-backup"` | Scheduled backup name | | backups.scheduledBackups[0].schedule | string | `"0 0 0 * * *"` | Schedule in cron format | | backups.secret.create | bool | `true` | Whether to create a secret for the backup credentials | @@ -182,6 +183,7 @@ Kubernetes: `>=1.29.0-0` | cluster.monitoring.prometheusRule.enabled | bool | `true` | Whether to enable the PrometheusRule automated alerts | | cluster.monitoring.prometheusRule.excludeRules | list | `[]` | Exclude specified rules | | cluster.monitoring.tls.enabled | bool | `false` | Whether to enable TLS on the metrics port. | +| cluster.plugins | list | `[]` | Plugins When adding `barman-cloud.cloudnative-pg.io`, just specify the plugin name and set `isWALArchiver` to true. The chart will then provision an `ObjectStore` resource with the configuration from the `backups.barmanObjectStore` section. | | cluster.podSecurityContext | object | `{}` | Configure the Pod Security Context. See: https://cloudnative-pg.io/documentation/preview/security/ | | cluster.postgresGID | int | `-1` | The GID of the postgres user inside the image, defaults to 26 | | cluster.postgresUID | int | `-1` | The UID of the postgres user inside the image, defaults to 26 | @@ -255,7 +257,7 @@ Kubernetes: `>=1.29.0-0` | recovery.import.source.sslRootCertSecret.name | string | `""` | | | recovery.import.source.username | string | `""` | | | recovery.import.type | string | `"microservice"` | One of `microservice` or `monolith.` See: https://cloudnative-pg.io/documentation/current/database_import/#how-it-works | -| recovery.method | string | `"backup"` | Available recovery methods: * `backup` - Recovers a CNPG cluster from a CNPG backup (PITR supported) Needs to be on the same cluster in the same namespace. * `object_store` - Recovers a CNPG cluster from a barman object store (PITR supported). * `pg_basebackup` - Recovers a CNPG cluster viaa streaming replication protocol. Useful if you want to migrate databases to CloudNativePG, even from outside Kubernetes. * `import` - Import one or more databases from an existing Postgres cluster. | +| recovery.method | string | `"backup"` | Available recovery methods: * `backup` - Recovers a CNPG cluster from a CNPG backup (PITR supported) Needs to be on the same cluster in the same namespace. * `plugin` - Recovers a CNPG cluster from a backup taken with a CloudNativePG plugin (e.g. barman-cloud). * `object_store` - Recovers a CNPG cluster from a barman object store (PITR supported). * `pg_basebackup` - Recovers a CNPG cluster viaa streaming replication protocol. Useful if you want to migrate databases to CloudNativePG, even from outside Kubernetes. * `import` - Import one or more databases from an existing Postgres cluster. | | recovery.owner | string | `""` | Name of the owner of the database in the instance to be used by applications. Defaults to the value of the `database` key. | | recovery.pgBaseBackup.database | string | `"app"` | Name of the database used by the application. Default: `app`. | | recovery.pgBaseBackup.owner | string | `""` | Name of the owner of the database in the instance to be used by applications. Defaults to the value of the `database` key. | @@ -277,6 +279,7 @@ Kubernetes: `>=1.29.0-0` | recovery.pgBaseBackup.source.username | string | `""` | | | recovery.pitrTarget | object | `{"time":""}` | Point in time recovery target. Specify one of the following: | | recovery.pitrTarget.time | string | `""` | Time in RFC3339 format | +| recovery.pluginConfiguration | string | `nil` | | | recovery.provider | string | `"s3"` | One of `s3`, `azure` or `google` | | recovery.s3.accessKey | string | `""` | | | recovery.s3.bucket | string | `""` | | diff --git a/charts/cluster/templates/NOTES.txt b/charts/cluster/templates/NOTES.txt index a0cc2fef3d..e9c60d26fa 100644 --- a/charts/cluster/templates/NOTES.txt +++ b/charts/cluster/templates/NOTES.txt @@ -87,7 +87,7 @@ Configuration │ Instances │ {{ include (printf "%s%s" "cluster.color-" $redundancyColor) (printf "%-56s" (toString .Values.cluster.instances)) }} │ │ Backups │ {{ include (printf "%s%s" "cluster.color-" (ternary "ok" "error" .Values.backups.enabled)) (printf "%-56s" (ternary "Enabled" "Disabled" .Values.backups.enabled)) }} │ {{- if .Values.backups.enabled }} -│ Backup Provider │ {{ printf "%-56s" (title .Values.backups.provider) }} │ +│ Backup Provider │ {{ printf "%-56s" (cat (title .Values.backups.method) (eq .Values.backups.method "plugin" | ternary (get (include "helpers.fetchKeyValue" (list .Values.cluster.plugins (list (list "isWALArchiver" true))) | fromYaml) "name") "")) }} │ │ Scheduled Backups │ {{ printf "%-56s" $scheduledBackups }} │ {{- end }} │ Storage │ {{ printf "%-56s" .Values.cluster.storage.size }} │ diff --git a/charts/cluster/templates/_backup.tpl b/charts/cluster/templates/_backup.tpl index 60270ea699..4d39284c74 100644 --- a/charts/cluster/templates/_backup.tpl +++ b/charts/cluster/templates/_backup.tpl @@ -1,5 +1,5 @@ {{- define "cluster.backup" -}} -{{- if .Values.backups.enabled }} +{{- if and .Values.backups.enabled ((eq .Values.backups.method "barmanObjectStore")) }} backup: target: "prefer-standby" retentionPolicy: {{ .Values.backups.retentionPolicy }} diff --git a/charts/cluster/templates/_bootstrap.tpl b/charts/cluster/templates/_bootstrap.tpl index c9b92f6ec3..14ecfaa824 100644 --- a/charts/cluster/templates/_bootstrap.tpl +++ b/charts/cluster/templates/_bootstrap.tpl @@ -91,6 +91,8 @@ bootstrap: name: {{ .Values.recovery.backupName }} {{- else if eq .Values.recovery.method "object_store" }} source: objectStoreRecoveryCluster + {{- else if eq .Values.recovery.method "plugin" }} + source: pluginRecoveryCluster {{- end }} {{- end }} {{- else if eq .Values.mode "replica" }} diff --git a/charts/cluster/templates/_external_clusters.tpl b/charts/cluster/templates/_external_clusters.tpl index f2b0e8fa1c..cd221620fe 100644 --- a/charts/cluster/templates/_external_clusters.tpl +++ b/charts/cluster/templates/_external_clusters.tpl @@ -1,7 +1,9 @@ {{- define "cluster.externalClusters" -}} {{- if eq .Values.mode "standalone" }} {{- else }} +{{- if not (and (eq .Values.mode "recovery") (eq .Values.recovery.method "backup")) }} externalClusters: +{{- end }} {{- if eq .Values.mode "recovery" }} {{- if eq .Values.recovery.method "pg_basebackup" }} - name: pgBaseBackupSource @@ -15,6 +17,17 @@ externalClusters: serverName: {{ .Values.recovery.clusterName }} {{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.recovery "secretPrefix" "recovery" -}} {{- include "cluster.barmanObjectStoreConfig" $d | nindent 4 }} + {{- else if eq .Values.recovery.method "plugin" }} + - name: pluginRecoveryCluster + plugin: + {{- omit .Values.recovery.pluginConfiguration "parameters" | toYaml | nindent 6 }} + parameters: + {{- $pluginConfigurationParameters := omit (coalesce .Values.recovery.pluginConfiguration.parameters dict) "barmanObjectName" -}} + {{ with $pluginConfigurationParameters }} + {{- toYaml . | nindent 8 -}} + {{ end }} + barmanObjectname: {{ include "cluster.fullname" . }}-recovery + serverName: {{ .Values.recovery.clusterName }} {{- end }} {{- else if eq .Values.mode "replica" }} - name: originCluster diff --git a/charts/cluster/templates/_helpers.tpl b/charts/cluster/templates/_helpers.tpl index 2bae419493..c642655635 100644 --- a/charts/cluster/templates/_helpers.tpl +++ b/charts/cluster/templates/_helpers.tpl @@ -144,3 +144,89 @@ Postgres GID {{- 26 -}} {{- end -}} {{- end -}} + + +{{/* +Check if a list of objects has a set key value pairs +*/}} +{{- /* Usage: {{ include "helpers.hasKeyValue" (list .Values.list (list (list "key" "value"))) }} */}} +{{- /* Returns the string true if the list has an item matching the key value pairs */}} +{{- define "helpers.hasKeyValue" -}} + {{- $list := index . 0 }} + {{- $kvPairs := index . 1 }} + + {{- range $list }} + {{- $item := . }} + {{- $valid := true }} + {{- range $kvPairs }} + {{- $key := index . 0 -}} + {{- $value := index . 1 -}} + {{- if or (not (hasKey $item $key)) (not (eq (get $item $key) $value)) -}} + {{- $valid = false -}} + {{- break -}} + {{- end -}} + {{- end -}} + {{- if $valid -}} + {{- "true" -}} + {{- break -}} + {{- end -}} + {{- end -}} +{{- end -}} + +{{/* +Similar to the omit function, returns a list of items that do not match the key value pairs +*/}} +{{- /* Usage: {{ include "helpers.omitKeyValue" (list .Values.list (list (list "key" "value"))) }} */}} +{{- /* Returns a YAML list without the items matching the key value pairs */}} +{{- define "helpers.omitKeyValue" -}} + {{- $list := index . 0 }} + {{- $kvPairs := index . 1 }} + {{- $newList := list }} + + {{- range $list }} + {{- $item := . }} + {{- $shouldOmit := false }} + {{- range $kvPairs }} + {{- $key := index . 0 -}} + {{- $value := index . 1 -}} + {{- if and (hasKey $item $key) (eq (get $item $key) $value) -}} + {{- $shouldOmit = true -}} + {{- end -}} + {{- end -}} + {{- if not $shouldOmit -}} + {{- $newList = append $newList $item -}} + {{- end -}} + {{- end -}} + {{- $newList | toYaml }} +{{ end -}} + + +{{/* +Given a list of objects, returns the first item that matches the key value pairs specified +*/}} +{{- /* Usage: {{ include "helpers.fetchKeyValue" (list .Values.list (list (list "key" "value"))) }} */}} +{{- /* Returns a YAML object of the first item in the list has an item matching the key value pairs */}} +{{- define "helpers.fetchKeyValue" -}} + {{- $list := index . 0 }} + {{- $kvPairs := index . 1 }} + {{- range $list }} + {{- $item := . }} + {{- $valid := true }} + {{- range $kvPairs }} + {{- $key := index . 0 -}} + {{- $value := index . 1 -}} + {{- if or (not (hasKey $item $key)) (not (eq (get $item $key) $value)) -}} + {{- $valid = false -}} + {{- break -}} + {{- end -}} + {{- end -}} + {{- if $valid -}} + {{- toYaml $item -}} + {{- break -}} + {{- end -}} + {{- end -}} +{{- end -}} + +{{- define "cluster.barmanPluginEnabled" -}} + {{- eq (include "helpers.hasKeyValue" (list .Values.cluster.plugins (list (list "name" "barman-cloud.cloudnative-pg.io") (list "isWALArchiver" true)))) "true" -}} +{{- end -}} diff --git a/charts/cluster/templates/backup-objectstore.yaml b/charts/cluster/templates/backup-objectstore.yaml new file mode 100644 index 0000000000..ddde8917f1 --- /dev/null +++ b/charts/cluster/templates/backup-objectstore.yaml @@ -0,0 +1,36 @@ +{{- if and .Values.backups.enabled (eq (include "cluster.barmanPluginEnabled" .) "true") }} +apiVersion: barmancloud.cnpg.io/v1 +kind: ObjectStore +metadata: + name: {{ include "cluster.fullname" . }}-backup + namespace: {{ include "cluster.namespace" . }} + {{- with .Values.cluster.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} + labels: + {{- include "cluster.labels" . | nindent 4 }} + {{- with .Values.cluster.additionalLabels }} + {{ toYaml . | nindent 4 }} + {{- end }} +spec: + retentionPolicy: {{ .Values.backups.retentionPolicy }} + configuration: + wal: + compression: {{ .Values.backups.wal.compression }} + {{- if .Values.backups.wal.encryption }} + encryption: {{ .Values.backups.wal.encryption }} + {{- end }} + maxParallel: {{ .Values.backups.wal.maxParallel }} + data: + compression: {{ .Values.backups.data.compression }} + {{- if .Values.backups.data.encryption }} + encryption: {{ .Values.backups.data.encryption }} + {{- end }} + jobs: {{ .Values.backups.data.jobs }} + + {{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.backups "secretPrefix" "backup" }} + {{- include "cluster.barmanObjectStoreConfig" $d | nindent 2 }} + instanceSidecarConfiguration: + {{- .Values.backups.instanceSidecarConfiguration | toYaml | nindent 4 }} +{{- end }} diff --git a/charts/cluster/templates/ca-bundle.yaml b/charts/cluster/templates/ca-bundle.yaml index d4a27e1162..80981d68fb 100644 --- a/charts/cluster/templates/ca-bundle.yaml +++ b/charts/cluster/templates/ca-bundle.yaml @@ -1,3 +1,4 @@ +{{- if and .Values.backups.enabled (or ((eq .Values.backups.method "barmanObjectStore")) (eq (include "cluster.barmanPluginEnabled" .) "true")) }} {{- if .Values.backups.endpointCA.create }} apiVersion: v1 kind: Secret @@ -7,3 +8,4 @@ metadata: data: {{ .Values.backups.endpointCA.key | default "ca-bundle.crt" | quote }}: {{ .Values.backups.endpointCA.value }} {{- end }} +{{- end }} diff --git a/charts/cluster/templates/cluster.yaml b/charts/cluster/templates/cluster.yaml index a853019fed..9d8a3e8562 100644 --- a/charts/cluster/templates/cluster.yaml +++ b/charts/cluster/templates/cluster.yaml @@ -151,3 +151,23 @@ spec: {{ include "cluster.bootstrap" . | nindent 2 }} {{ include "cluster.externalClusters" . | nindent 2 }} {{ include "cluster.backup" . | nindent 2 }} + + {{- with .Values.cluster.plugins }} + plugins: + {{ $pluginsWithoutBarman := include "helpers.omitKeyValue" (list .Values.cluster.plugins (list (list "name" "barman-cloud.cloudnative-pg.io"))) | fromYamlArray }} + {{- range $pluginsWithoutBarman -}} + - {{ toYaml . | indent 6 | trim }} + {{- end }} + {{- if and .Values.backups.enabled (eq (include "cluster.barmanPluginEnabled" .) "true") (eq .Values.backups.method "plugin") }} + {{- $barmanPlugin := include "helpers.fetchKeyValue" (list .Values.cluster.plugins (list (list "name" "barman-cloud.cloudnative-pg.io"))) | fromYaml -}} + - name: {{ $barmanPlugin.name }} + enabled: true + isWALArchiver: true + parameters: + {{- $parameters := (omit (coalesce $barmanPlugin.parameters dict) "barmanObjectName") -}} + {{ with $parameters }} + {{ toYaml . | indent 8 | trim }} + {{- end }} + barmanObjectName: {{ include "cluster.fullname" . }}-backup + {{- end }} + {{- end }} diff --git a/charts/cluster/templates/recovery-objectstore.yaml b/charts/cluster/templates/recovery-objectstore.yaml new file mode 100644 index 0000000000..8ae69b967e --- /dev/null +++ b/charts/cluster/templates/recovery-objectstore.yaml @@ -0,0 +1,23 @@ +{{- if and (eq .Values.mode "recovery") (eq .Values.recovery.method "plugin") (eq .Values.recovery.pluginConfiguration.name "barman-cloud.cloudnative-pg.io") }} +apiVersion: barmancloud.cnpg.io/v1 +kind: ObjectStore +metadata: + name: {{ include "cluster.fullname" . }}-recovery + namespace: {{ include "cluster.namespace" . }} + {{- with .Values.cluster.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} + labels: + {{- include "cluster.labels" . | nindent 4 }} + {{- with .Values.cluster.additionalLabels }} + {{ toYaml . | nindent 4 }} + {{- end }} +spec: + configuration: + {{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.recovery "secretPrefix" "recovery" -}} + {{- include "cluster.barmanObjectStoreConfig" $d | indent 2 }} + retentionPolicy: {{ .Values.recovery.retentionPolicy }} + instanceSidecarConfiguration: + {{- .Values.recovery.instanceSidecarConfiguration | toYaml | nindent 4 }} +{{- end }} diff --git a/charts/cluster/templates/scheduled-backups.yaml b/charts/cluster/templates/scheduled-backups.yaml index 4db3d56c5f..4821d070ed 100644 --- a/charts/cluster/templates/scheduled-backups.yaml +++ b/charts/cluster/templates/scheduled-backups.yaml @@ -16,5 +16,9 @@ spec: backupOwnerReference: {{ .backupOwnerReference }} cluster: name: {{ include "cluster.fullname" $context }} + {{- with .pluginConfiguration }} + pluginConfiguration: + {{- toYaml . | nindent 4 }} + {{ end }} {{ end -}} {{ end }} diff --git a/charts/cluster/values.schema.json b/charts/cluster/values.schema.json index 9d4e44357b..a8c34c32e4 100644 --- a/charts/cluster/values.schema.json +++ b/charts/cluster/values.schema.json @@ -123,6 +123,11 @@ "required": [], "type": "object" }, + "method": { + "default": "barmanObjectStore", + "description": "One of `barmanObjectStore` (default) or `plugin`", + "type": "string" + }, "provider": { "default": "s3", "description": "One of `s3`, `azure` or `google`", @@ -176,7 +181,7 @@ }, "method": { "default": "barmanObjectStore", - "description": "Backup method, can be `barmanObjectStore` (default) or `volumeSnapshot`", + "description": "Backup method, can be `barmanObjectStore` (default), `volumeSnapshot` or `plugin`.", "type": "string" }, "name": { @@ -444,6 +449,13 @@ "required": [], "type": "object" }, + "plugins": { + "description": "Plugins\nWhen adding `barman-cloud.cloudnative-pg.io`, just specify the plugin name and set `isWALArchiver` to true. The\nchart will then provision an `ObjectStore` resource with the configuration from the `backups.barmanObjectStore` section.", + "items": { + "required": [] + }, + "type": "array" + }, "podSecurityContext": { "description": "Configure the Pod Security Context.\nSee: https://cloudnative-pg.io/documentation/preview/security/", "required": [], @@ -903,7 +915,7 @@ }, "method": { "default": "backup", - "description": "Available recovery methods:\n* `backup` - Recovers a CNPG cluster from a CNPG backup (PITR supported) Needs to be on the same cluster in the same namespace.\n* `object_store` - Recovers a CNPG cluster from a barman object store (PITR supported).\n* `pg_basebackup` - Recovers a CNPG cluster viaa streaming replication protocol. Useful if you want to\n migrate databases to CloudNativePG, even from outside Kubernetes.\n* `import` - Import one or more databases from an existing Postgres cluster.", + "description": "Available recovery methods:\n* `backup` - Recovers a CNPG cluster from a CNPG backup (PITR supported) Needs to be on the same cluster in the same namespace.\n* `plugin` - Recovers a CNPG cluster from a backup taken with a CloudNativePG plugin (e.g. barman-cloud).\n* `object_store` - Recovers a CNPG cluster from a barman object store (PITR supported).\n* `pg_basebackup` - Recovers a CNPG cluster viaa streaming replication protocol. Useful if you want to\n migrate databases to CloudNativePG, even from outside Kubernetes.\n* `import` - Import one or more databases from an existing Postgres cluster.", "type": "string" }, "owner": { @@ -1039,6 +1051,10 @@ "required": [], "type": "object" }, + "pluginConfiguration": { + "default": "", + "type": "null" + }, "provider": { "default": "s3", "description": "One of `s3`, `azure` or `google`", diff --git a/charts/cluster/values.yaml b/charts/cluster/values.yaml index 52c7cf8045..5d342e3596 100644 --- a/charts/cluster/values.yaml +++ b/charts/cluster/values.yaml @@ -28,6 +28,7 @@ mode: standalone recovery: # -- Available recovery methods: # * `backup` - Recovers a CNPG cluster from a CNPG backup (PITR supported) Needs to be on the same cluster in the same namespace. + # * `plugin` - Recovers a CNPG cluster from a backup taken with a CloudNativePG plugin (e.g. barman-cloud). # * `object_store` - Recovers a CNPG cluster from a barman object store (PITR supported). # * `pg_basebackup` - Recovers a CNPG cluster viaa streaming replication protocol. Useful if you want to # migrate databases to CloudNativePG, even from outside Kubernetes. @@ -48,6 +49,15 @@ recovery: database: app # -- Name of the owner of the database in the instance to be used by applications. Defaults to the value of the `database` key. owner: "" + + pluginConfiguration: + #name: barman-cloud.cloudnative-pg.io + #parameters: + # serverName: cluster-example + + # Barman Object Store configuration applicable to both `barmanObjectStore` and `plugin` methods when using + # the `barman-cloud.cloudnative-pg.io` plugin. + # -- Overrides the provider specific default endpoint. endpointURL: "" # Defaults to: @@ -289,6 +299,14 @@ cluster: # See: https://cloudnative-pg.io/documentation/current/kubernetes_upgrade/#pod-disruption-budgets enablePDB: true + # -- Plugins + # When adding `barman-cloud.cloudnative-pg.io`, just specify the plugin name and set `isWALArchiver` to true. The + # chart will then provision an `ObjectStore` resource with the configuration from the `backups.barmanObjectStore` section. + plugins: [] + # - name: barman-cloud.cloudnative-pg.io + # enabled: true + # isWALArchiver: true + # -- This feature enables declarative management of existing roles, as well as the creation of new roles if they are not # already present in the database. # See: https://cloudnative-pg.io/documentation/current/declarative_role_management/ @@ -442,6 +460,12 @@ backups: # -- You need to configure backups manually, so backups are disabled by default. enabled: false + # -- One of `barmanObjectStore` (default) or `plugin` + method: barmanObjectStore + + # Barman Object Store configuration applicable to both `barmanObjectStore` and `plugin` methods when using + # the `barman-cloud.cloudnative-pg.io` plugin. + # -- Overrides the provider specific default endpoint. endpointURL: "" # Defaults to: @@ -516,8 +540,10 @@ backups: schedule: "0 0 0 * * *" # -- Backup owner reference backupOwnerReference: self - # -- Backup method, can be `barmanObjectStore` (default) or `volumeSnapshot` + # -- Backup method, can be `barmanObjectStore` (default), `volumeSnapshot` or `plugin`. method: barmanObjectStore + #pluginConfiguration: + # name: barman-cloud.cloudnative-pg.io # -- Retention policy for backups retentionPolicy: "30d" From 49b78f9474c271c1c1da858cedf8562da3d8dc0d Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Sat, 20 Jun 2026 14:31:02 +0300 Subject: [PATCH 02/43] ci: installing cert manager and the Barman CNPG-I plugin Signed-off-by: Itay Grudev --- .github/workflows/tests-cluster-chainsaw.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/tests-cluster-chainsaw.yaml b/.github/workflows/tests-cluster-chainsaw.yaml index 90e07b4614..140a8cb129 100644 --- a/.github/workflows/tests-cluster-chainsaw.yaml +++ b/.github/workflows/tests-cluster-chainsaw.yaml @@ -42,6 +42,15 @@ jobs: - name: Deploy the operator uses: ./.github/actions/deploy-operator + - name: Install cert-manager + uses: ./.github/actions/deploy-cert-manager + + - name: Install Barman CNPG-I plugin + run: | + helm upgrade --install plugin-barman-cloud \ + --namespace cnpg-system \ + ./charts/plugin-barman-cloud + - name: Install Prometheus CRDs run: | helm repo add prometheus-community https://prometheus-community.github.io/helm-charts From 74b21547866adf5b717b66e4670587988576f2b1 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Sat, 20 Jun 2026 14:31:39 +0300 Subject: [PATCH 03/43] added instanceSidecarConfiguration Signed-off-by: Itay Grudev --- charts/cluster/README.md | 2 ++ charts/cluster/values.schema.json | 10 ++++++++++ charts/cluster/values.yaml | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/charts/cluster/README.md b/charts/cluster/README.md index 5590f7ab1e..042414e8d5 100644 --- a/charts/cluster/README.md +++ b/charts/cluster/README.md @@ -136,6 +136,7 @@ Kubernetes: `>=1.29.0-0` | backups.google.bucket | string | `""` | | | backups.google.gkeEnvironment | bool | `false` | | | backups.google.path | string | `"/"` | | +| backups.instanceSidecarConfiguration | object | `{}` | The configuration for the Barman Cloud Plugin sidecar that runs in the instance pods. See: https://cloudnative-pg.io/plugin-barman-cloud/docs/next/plugin-barman-cloud.v1/#instancesidecarconfiguration | | backups.method | string | `"barmanObjectStore"` | One of `barmanObjectStore` (default) or `plugin` | | backups.provider | string | `"s3"` | One of `s3`, `azure` or `google` | | backups.retentionPolicy | string | `"30d"` | Retention policy for backups | @@ -257,6 +258,7 @@ Kubernetes: `>=1.29.0-0` | recovery.import.source.sslRootCertSecret.name | string | `""` | | | recovery.import.source.username | string | `""` | | | recovery.import.type | string | `"microservice"` | One of `microservice` or `monolith.` See: https://cloudnative-pg.io/documentation/current/database_import/#how-it-works | +| recovery.instanceSidecarConfiguration | object | `{}` | The configuration for the Barman Cloud Plugin sidecar that runs in the instance pods. See: https://cloudnative-pg.io/plugin-barman-cloud/docs/next/plugin-barman-cloud.v1/#instancesidecarconfiguration | | recovery.method | string | `"backup"` | Available recovery methods: * `backup` - Recovers a CNPG cluster from a CNPG backup (PITR supported) Needs to be on the same cluster in the same namespace. * `plugin` - Recovers a CNPG cluster from a backup taken with a CloudNativePG plugin (e.g. barman-cloud). * `object_store` - Recovers a CNPG cluster from a barman object store (PITR supported). * `pg_basebackup` - Recovers a CNPG cluster viaa streaming replication protocol. Useful if you want to migrate databases to CloudNativePG, even from outside Kubernetes. * `import` - Import one or more databases from an existing Postgres cluster. | | recovery.owner | string | `""` | Name of the owner of the database in the instance to be used by applications. Defaults to the value of the `database` key. | | recovery.pgBaseBackup.database | string | `"app"` | Name of the database used by the application. Default: `app`. | diff --git a/charts/cluster/values.schema.json b/charts/cluster/values.schema.json index a8c34c32e4..789d67421d 100644 --- a/charts/cluster/values.schema.json +++ b/charts/cluster/values.schema.json @@ -123,6 +123,11 @@ "required": [], "type": "object" }, + "instanceSidecarConfiguration": { + "description": "The configuration for the Barman Cloud Plugin sidecar that runs in the instance pods. See: https://cloudnative-pg.io/plugin-barman-cloud/docs/next/plugin-barman-cloud.v1/#instancesidecarconfiguration", + "required": [], + "type": "object" + }, "method": { "default": "barmanObjectStore", "description": "One of `barmanObjectStore` (default) or `plugin`", @@ -913,6 +918,11 @@ "required": [], "type": "object" }, + "instanceSidecarConfiguration": { + "description": "The configuration for the Barman Cloud Plugin sidecar that runs in the instance pods. See: https://cloudnative-pg.io/plugin-barman-cloud/docs/next/plugin-barman-cloud.v1/#instancesidecarconfiguration", + "required": [], + "type": "object" + }, "method": { "default": "backup", "description": "Available recovery methods:\n* `backup` - Recovers a CNPG cluster from a CNPG backup (PITR supported) Needs to be on the same cluster in the same namespace.\n* `plugin` - Recovers a CNPG cluster from a backup taken with a CloudNativePG plugin (e.g. barman-cloud).\n* `object_store` - Recovers a CNPG cluster from a barman object store (PITR supported).\n* `pg_basebackup` - Recovers a CNPG cluster viaa streaming replication protocol. Useful if you want to\n migrate databases to CloudNativePG, even from outside Kubernetes.\n* `import` - Import one or more databases from an existing Postgres cluster.", diff --git a/charts/cluster/values.yaml b/charts/cluster/values.yaml index 5d342e3596..81b16ae241 100644 --- a/charts/cluster/values.yaml +++ b/charts/cluster/values.yaml @@ -108,6 +108,9 @@ recovery: # -- Name of the backup credentials secret name: "" + # -- The configuration for the Barman Cloud Plugin sidecar that runs in the instance pods. See: https://cloudnative-pg.io/plugin-barman-cloud/docs/next/plugin-barman-cloud.v1/#instancesidecarconfiguration + instanceSidecarConfiguration: {} + # See https://cloudnative-pg.io/documentation/current/bootstrap/#bootstrap-from-a-live-cluster-pg_basebackup pgBaseBackup: # -- Name of the database used by the application. Default: `app`. @@ -517,6 +520,9 @@ backups: # -- Name of the backup credentials secret name: "" + # -- The configuration for the Barman Cloud Plugin sidecar that runs in the instance pods. See: https://cloudnative-pg.io/plugin-barman-cloud/docs/next/plugin-barman-cloud.v1/#instancesidecarconfiguration + instanceSidecarConfiguration: {} + wal: # -- WAL compression method. One of `` (for no compression), `gzip`, `bzip2` or `snappy`. compression: gzip From 5f0ab225b22c166506cfe41e16f04a89faa958a8 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Sat, 20 Jun 2026 14:32:09 +0300 Subject: [PATCH 04/43] fix: plugin section not working correctly Signed-off-by: Itay Grudev --- charts/cluster/templates/backup-objectstore.yaml | 2 +- charts/cluster/templates/cluster.yaml | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/charts/cluster/templates/backup-objectstore.yaml b/charts/cluster/templates/backup-objectstore.yaml index ddde8917f1..0c23c12c25 100644 --- a/charts/cluster/templates/backup-objectstore.yaml +++ b/charts/cluster/templates/backup-objectstore.yaml @@ -2,7 +2,7 @@ apiVersion: barmancloud.cnpg.io/v1 kind: ObjectStore metadata: - name: {{ include "cluster.fullname" . }}-backup + name: {{ include "cluster.fullname" . }}-backups namespace: {{ include "cluster.namespace" . }} {{- with .Values.cluster.annotations }} annotations: diff --git a/charts/cluster/templates/cluster.yaml b/charts/cluster/templates/cluster.yaml index 9d8a3e8562..c2b0d98e88 100644 --- a/charts/cluster/templates/cluster.yaml +++ b/charts/cluster/templates/cluster.yaml @@ -148,11 +148,13 @@ spec: {{- end }} tls: enabled: {{ .Values.cluster.monitoring.tls.enabled }} - {{ include "cluster.bootstrap" . | nindent 2 }} - {{ include "cluster.externalClusters" . | nindent 2 }} - {{ include "cluster.backup" . | nindent 2 }} - {{- with .Values.cluster.plugins }} + {{ include "cluster.bootstrap" . | nindent 2 -}} + {{ include "cluster.externalClusters" . | nindent 2 -}} + {{ include "cluster.backup" . | nindent 2 -}} + + {{- $plugins := len .Values.cluster.plugins -}} + {{- if and (gt $plugins 0) (or (gt $plugins 1) (and .Values.backups.enabled (eq (include "cluster.barmanPluginEnabled" .) "true") (eq .Values.backups.method "plugin"))) }} plugins: {{ $pluginsWithoutBarman := include "helpers.omitKeyValue" (list .Values.cluster.plugins (list (list "name" "barman-cloud.cloudnative-pg.io"))) | fromYamlArray }} {{- range $pluginsWithoutBarman -}} @@ -168,6 +170,6 @@ spec: {{ with $parameters }} {{ toYaml . | indent 8 | trim }} {{- end }} - barmanObjectName: {{ include "cluster.fullname" . }}-backup + barmanObjectName: {{ include "cluster.fullname" . }}-backups {{- end }} {{- end }} From c42be2b04709bab572d546635d236993ce1db822 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Sat, 20 Jun 2026 15:23:35 +0300 Subject: [PATCH 05/43] barman plugin e2e chainsaw prototype tests Signed-off-by: Itay Grudev --- .../00-minio_cleanup-assert.yaml | 6 + .../00-minio_cleanup.yaml | 16 ++ ...-plugin-backup-restore_cluster-assert.yaml | 6 + ...-barman-plugin-backup-restore_cluster.yaml | 31 ++++ .../02-data_write-assert.yaml | 6 + .../02-data_write.yaml | 54 ++++++ .../03-backup.yaml | 10 + .../03-backup_completed-assert.yaml | 12 ++ .../03-backup_running-assert.yaml | 12 ++ .../03-checkpoint.yaml | 27 +++ .../04-post_backup_data_write-assert.yaml | 6 + .../04-post_backup_data_write.yaml | 27 +++ ...5-recovery_backup_pitr_cluster-assert.yaml | 6 + .../05-recovery_backup_pitr_cluster.yaml | 56 ++++++ .../06-data_test-assert.yaml | 6 + .../06-data_test.yaml | 27 +++ .../chainsaw-test.yaml | 120 ++++++++++++ .../00-minio_cleanup-assert.yaml | 6 + .../00-minio_cleanup.yaml | 16 ++ ...arman-plugin-migration_cluster-assert.yaml | 7 + .../01-barman-plugin-migration_cluster.yaml | 27 +++ .../barman-plugin-migration/02-backup.yaml | 7 + .../02-backup_completed-assert.yaml | 9 + .../02-checkpoint.yaml | 27 +++ .../03-data_write-assert.yaml | 6 + .../03-data_write.yaml | 54 ++++++ ...arman-plugin-migration_cluster-assert.yaml | 12 ++ .../04.1-barman-plugin-migration_cluster.yaml | 31 ++++ ...arman-plugin-migration_cluster-assert.yaml | 17 ++ .../04.2-barman-plugin-migration_cluster.yaml | 31 ++++ .../barman-plugin-migration/05-backup.yaml | 10 + .../05-backup_completed-assert.yaml | 12 ++ .../05-backup_running-assert.yaml | 12 ++ .../05-checkpoint.yaml | 27 +++ .../06-post_backup_data_write-assert.yaml | 6 + .../06-post_backup_data_write.yaml | 27 +++ ...7-recovery_backup_pitr_cluster-assert.yaml | 6 + .../07-recovery_backup_pitr_cluster.yaml | 50 +++++ .../08-data_test-assert.yaml | 6 + .../barman-plugin-migration/08-data_test.yaml | 27 +++ .../chainsaw-test.yaml | 173 ++++++++++++++++++ .../00-minio_cleanup-assert.yaml | 6 + .../00-minio_cleanup.yaml | 16 ++ .../01-scheduledbackups_cluster-assert.yaml | 62 +++++++ .../01-scheduledbackups_cluster.yaml | 43 +++++ .../01.1-checkpoint.yaml | 27 +++ .../chainsaw-test.yaml | 31 ++++ 47 files changed, 1219 insertions(+) create mode 100644 charts/cluster/test/barman-plugin-backup-restore/00-minio_cleanup-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-backup-restore/00-minio_cleanup.yaml create mode 100644 charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster.yaml create mode 100644 charts/cluster/test/barman-plugin-backup-restore/02-data_write-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-backup-restore/02-data_write.yaml create mode 100644 charts/cluster/test/barman-plugin-backup-restore/03-backup.yaml create mode 100644 charts/cluster/test/barman-plugin-backup-restore/03-backup_completed-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-backup-restore/03-backup_running-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-backup-restore/03-checkpoint.yaml create mode 100644 charts/cluster/test/barman-plugin-backup-restore/04-post_backup_data_write-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-backup-restore/04-post_backup_data_write.yaml create mode 100644 charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml create mode 100644 charts/cluster/test/barman-plugin-backup-restore/06-data_test-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-backup-restore/06-data_test.yaml create mode 100644 charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/00-minio_cleanup-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/00-minio_cleanup.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/01-barman-plugin-migration_cluster-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/01-barman-plugin-migration_cluster.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/02-backup.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/02-backup_completed-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/02-checkpoint.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/03-data_write-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/03-data_write.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/05-backup.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/05-backup_completed-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/05-backup_running-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/05-checkpoint.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/06-post_backup_data_write-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/06-post_backup_data_write.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/07-recovery_backup_pitr_cluster-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/07-recovery_backup_pitr_cluster.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/08-data_test-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/08-data_test.yaml create mode 100644 charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml create mode 100644 charts/cluster/test/barman-plugin-scheduledbackups/00-minio_cleanup-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-scheduledbackups/00-minio_cleanup.yaml create mode 100644 charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml create mode 100644 charts/cluster/test/barman-plugin-scheduledbackups/01.1-checkpoint.yaml create mode 100644 charts/cluster/test/barman-plugin-scheduledbackups/chainsaw-test.yaml diff --git a/charts/cluster/test/barman-plugin-backup-restore/00-minio_cleanup-assert.yaml b/charts/cluster/test/barman-plugin-backup-restore/00-minio_cleanup-assert.yaml new file mode 100644 index 0000000000..9c0f3eb480 --- /dev/null +++ b/charts/cluster/test/barman-plugin-backup-restore/00-minio_cleanup-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: minio-cleanup +status: + succeeded: 1 diff --git a/charts/cluster/test/barman-plugin-backup-restore/00-minio_cleanup.yaml b/charts/cluster/test/barman-plugin-backup-restore/00-minio_cleanup.yaml new file mode 100644 index 0000000000..bc381b893f --- /dev/null +++ b/charts/cluster/test/barman-plugin-backup-restore/00-minio_cleanup.yaml @@ -0,0 +1,16 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: minio-cleanup +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: minio-cleanup + image: minio/mc + command: ['sh', '-c'] + args: + - | + mc alias set myminio https://minio.minio.svc.cluster.local minio minio123 + mc rm --recursive --force myminio/mybucket/barman-plugin-backup-restore diff --git a/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster-assert.yaml b/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster-assert.yaml new file mode 100644 index 0000000000..64335d206e --- /dev/null +++ b/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: barman-plugin-backup-restore-cluster +status: + readyInstances: 2 diff --git a/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster.yaml b/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster.yaml new file mode 100644 index 0000000000..22735eee56 --- /dev/null +++ b/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster.yaml @@ -0,0 +1,31 @@ +type: postgresql +mode: standalone +cluster: + instances: 2 + storage: + size: 256Mi + plugins: + - name: barman-cloud.cloudnative-pg.io + enabled: true + isWALArchiver: true + +backups: + enabled: true + method: plugin + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/barman-plugin-backup-restore/v1" + accessKey: "minio" + secretKey: "minio123" + region: "local" + scheduledBackups: [] + retentionPolicy: "30d" diff --git a/charts/cluster/test/barman-plugin-backup-restore/02-data_write-assert.yaml b/charts/cluster/test/barman-plugin-backup-restore/02-data_write-assert.yaml new file mode 100644 index 0000000000..831f963d9d --- /dev/null +++ b/charts/cluster/test/barman-plugin-backup-restore/02-data_write-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-write +status: + succeeded: 1 diff --git a/charts/cluster/test/barman-plugin-backup-restore/02-data_write.yaml b/charts/cluster/test/barman-plugin-backup-restore/02-data_write.yaml new file mode 100644 index 0000000000..1093ad0168 --- /dev/null +++ b/charts/cluster/test/barman-plugin-backup-restore/02-data_write.yaml @@ -0,0 +1,54 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: configmap-creator-sa +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: configmap-creator +rules: +- apiGroups: [""] + resources: ["configmaps"] + verbs: ["create"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: configmap-creator-binding +subjects: +- kind: ServiceAccount + name: configmap-creator-sa +roleRef: + kind: Role + name: configmap-creator + apiGroup: rbac.authorization.k8s.io +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: data-write +spec: + template: + spec: + serviceAccountName: configmap-creator-sa + restartPolicy: OnFailure + containers: + - name: data-write + env: + - name: DB_URI + valueFrom: + secretKeyRef: + name: barman-plugin-backup-restore-cluster-superuser + key: uri + image: alpine:3.19 + command: ['sh', '-c'] + args: + - | + apk --no-cache add postgresql-client kubectl coreutils + DB_URI=$(echo $DB_URI | sed "s|/\*|/|" ) + psql "$DB_URI" -c "CREATE TABLE mygoodtable (id serial PRIMARY KEY);" + sleep 5 + DATE_NO_BAD_TABLE=$(date --rfc-3339=ns) + kubectl create configmap date-no-bad-table --from-literal=date="$DATE_NO_BAD_TABLE" + sleep 5 diff --git a/charts/cluster/test/barman-plugin-backup-restore/03-backup.yaml b/charts/cluster/test/barman-plugin-backup-restore/03-backup.yaml new file mode 100644 index 0000000000..508e58106d --- /dev/null +++ b/charts/cluster/test/barman-plugin-backup-restore/03-backup.yaml @@ -0,0 +1,10 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +metadata: + name: post-init-backup +spec: + cluster: + name: barman-plugin-backup-restore-cluster + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io diff --git a/charts/cluster/test/barman-plugin-backup-restore/03-backup_completed-assert.yaml b/charts/cluster/test/barman-plugin-backup-restore/03-backup_completed-assert.yaml new file mode 100644 index 0000000000..aa81876de0 --- /dev/null +++ b/charts/cluster/test/barman-plugin-backup-restore/03-backup_completed-assert.yaml @@ -0,0 +1,12 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +metadata: + name: post-init-backup +spec: + cluster: + name: barman-plugin-backup-restore-cluster + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io +status: + phase: completed diff --git a/charts/cluster/test/barman-plugin-backup-restore/03-backup_running-assert.yaml b/charts/cluster/test/barman-plugin-backup-restore/03-backup_running-assert.yaml new file mode 100644 index 0000000000..e708dd4429 --- /dev/null +++ b/charts/cluster/test/barman-plugin-backup-restore/03-backup_running-assert.yaml @@ -0,0 +1,12 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +metadata: + name: post-init-backup +spec: + cluster: + name: barman-plugin-backup-restore-cluster + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io +status: + phase: running diff --git a/charts/cluster/test/barman-plugin-backup-restore/03-checkpoint.yaml b/charts/cluster/test/barman-plugin-backup-restore/03-checkpoint.yaml new file mode 100644 index 0000000000..83e50ab849 --- /dev/null +++ b/charts/cluster/test/barman-plugin-backup-restore/03-checkpoint.yaml @@ -0,0 +1,27 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: backup-checkpoint +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: create-checkpoint + env: + - name: DB_URI + valueFrom: + secretKeyRef: + name: barman-plugin-backup-restore-cluster-superuser + key: uri + image: alpine:3.19 + command: ['sh', '-c'] + args: + - | + apk --no-cache add postgresql-client + DB_URI=$(echo $DB_URI | sed "s|/\*|/|" ) + END_TIME=$(( $(date +%s) + 30 )) + while [ $(date +%s) -lt $END_TIME ]; do + psql "$DB_URI" -c "SELECT pg_switch_wal();CHECKPOINT;" + sleep 5 + done diff --git a/charts/cluster/test/barman-plugin-backup-restore/04-post_backup_data_write-assert.yaml b/charts/cluster/test/barman-plugin-backup-restore/04-post_backup_data_write-assert.yaml new file mode 100644 index 0000000000..ad9be77a7b --- /dev/null +++ b/charts/cluster/test/barman-plugin-backup-restore/04-post_backup_data_write-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-write-post-backup +status: + succeeded: 1 diff --git a/charts/cluster/test/barman-plugin-backup-restore/04-post_backup_data_write.yaml b/charts/cluster/test/barman-plugin-backup-restore/04-post_backup_data_write.yaml new file mode 100644 index 0000000000..c79858c652 --- /dev/null +++ b/charts/cluster/test/barman-plugin-backup-restore/04-post_backup_data_write.yaml @@ -0,0 +1,27 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-write-post-backup +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: data-write + env: + - name: DB_URI + valueFrom: + secretKeyRef: + name: barman-plugin-backup-restore-cluster-superuser + key: uri + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + image: alpine:3.19 + command: ['sh', '-c'] + args: + - | + apk --no-cache add postgresql-client + DB_URI=$(echo $DB_URI | sed "s|/\*|/|" ) + psql "$DB_URI" -c "CREATE TABLE mybadtable (id serial PRIMARY KEY);" diff --git a/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster-assert.yaml b/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster-assert.yaml new file mode 100644 index 0000000000..2b6b9651f1 --- /dev/null +++ b/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: recovery-backup-pitr-cluster +status: + readyInstances: 2 diff --git a/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml b/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml new file mode 100644 index 0000000000..a138ec0c2d --- /dev/null +++ b/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml @@ -0,0 +1,56 @@ +type: postgresql +mode: recovery + +cluster: + instances: 2 + storage: + size: 256Mi + plugins: + - name: barman-cloud.cloudnative-pg.io + enabled: true + isWALArchiver: true + +recovery: + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/barman-plugin-backup-restore/v1" + accessKey: "minio" + secretKey: "minio123" + region: "local" + clusterName: "barman-plugin-backup-restore" + retentionPolicy: "30d" + scheduledBackups: [] + +backups: + enabled: true + method: plugin + barmanObjectStore: + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/barman-plugin-backup-restore/v2" + accessKey: "minio" + secretKey: "minio123" + region: "local" + scheduledBackups: [] + retentionPolicy: "30d" diff --git a/charts/cluster/test/barman-plugin-backup-restore/06-data_test-assert.yaml b/charts/cluster/test/barman-plugin-backup-restore/06-data_test-assert.yaml new file mode 100644 index 0000000000..6f14d5f231 --- /dev/null +++ b/charts/cluster/test/barman-plugin-backup-restore/06-data_test-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-test-backup-pitr +status: + succeeded: 1 diff --git a/charts/cluster/test/barman-plugin-backup-restore/06-data_test.yaml b/charts/cluster/test/barman-plugin-backup-restore/06-data_test.yaml new file mode 100644 index 0000000000..5fb4faf395 --- /dev/null +++ b/charts/cluster/test/barman-plugin-backup-restore/06-data_test.yaml @@ -0,0 +1,27 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-test-backup-pitr +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: data-test + env: + - name: DB_URI + valueFrom: + secretKeyRef: + name: recovery-backup-pitr-cluster-superuser + key: uri + image: alpine:3.19 + command: ['sh', '-c'] + args: + - | + apk --no-cache add postgresql-client + DB_URI=$(echo $DB_URI | sed "s|/\*|/|" ) + set -e + test "$(psql $DB_URI -t -c 'SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = $$mygoodtable$$)' --csv -q 2>/dev/null)" = "t" + echo "Good table exists" + test "$(psql $DB_URI -t -c 'SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = $$mybadtable$$)' --csv -q 2>/dev/null)" = "f" + echo "Bad table does not exist" diff --git a/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml new file mode 100644 index 0000000000..ebd6f539fd --- /dev/null +++ b/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml @@ -0,0 +1,120 @@ +## +# This test CNPG Cluster backups and PITR recovery with the Barman Cloud CNPG-I plugin +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + name: barman-plugin-backup-restore +spec: + timeouts: + apply: 1s + assert: 7m + cleanup: 1m + steps: + - name: Clear the MinIO bucket + try: + - apply: + file: ./00-minio_cleanup.yaml + - assert: + file: ./00-minio_cleanup-assert.yaml + - name: Install a standalone CNPG Cluster + try: + - script: + content: | + kubectl -n $NAMESPACE create secret generic kube-root-ca.crt --from-literal=ca.crt="$(kubectl -n kube-system get configmaps kube-root-ca.crt -o jsonpath='{.data.ca\.crt}')" --dry-run=client -o yaml | kubectl apply -f - + helm upgrade \ + --install \ + --namespace $NAMESPACE \ + --values ./01-barman-plugin-backup-restore_cluster.yaml \ + --wait \ + barman-plugin-backup-restore ../../ + - assert: + file: ./01-barman-plugin-backup-restore_cluster-assert.yaml + catch: + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Cluster + - podLogs: + selector: cnpg.io/cluster=barman-plugin-backup-restore-cluster + - name: Write some data to the cluster + timeouts: + apply: 1s + assert: 30s + try: + - apply: + file: ./02-data_write.yaml + - assert: + file: ./02-data_write-assert.yaml + catch: + - describe: + apiVersion: batch/v1 + kind: Job + - podLogs: + selector: batch.kubernetes.io/job-name=data-test + - name: Create a backup + try: + - apply: + file: ./03-backup.yaml + - apply: + file: ./03-checkpoint.yaml + - assert: + file: ./03-backup_completed-assert.yaml + catch: + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Backup + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Cluster + - podLogs: + selector: cnpg.io/cluster=barman-plugin-backup-restore-cluster + - name: Write more data to the database after the backup + try: + - apply: + file: ./04-post_backup_data_write.yaml + - assert: + file: ./04-post_backup_data_write-assert.yaml + timeouts: + apply: 1s + assert: 10m + catch: + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Backup + - name: Create a recovery cluster from backup with a PITR target + try: + - script: + content: | + DATE_NO_BAD_TABLE=$(kubectl -n $NAMESPACE get configmap date-no-bad-table -o 'jsonpath={.data.date}') + helm upgrade \ + --install \ + --namespace $NAMESPACE \ + --values ./05-recovery_backup_pitr_cluster.yaml \ + --set recovery.pitrTarget.time="$DATE_NO_BAD_TABLE" \ + --wait \ + recovery-backup-pitr ../../ + - assert: + file: ./05-recovery_backup_pitr_cluster-assert.yaml + catch: + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Cluster + - podLogs: + selector: cnpg.io/cluster=recovery-backup-pitr-cluster + - name: Verify the pre-backup data on the recovery cluster exists but not the post-backup data + try: + - apply: + file: ./06-data_test.yaml + - assert: + file: ./06-data_test-assert.yaml + catch: + - describe: + apiVersion: batch/v1 + kind: Job + selector: batch.kubernetes.io/job-name=data-test-backup-pitr + - podLogs: + selector: batch.kubernetes.io/job-name=data-test-backup-pitr + - name: Cleanup + try: + - script: + content: | + helm uninstall --namespace $NAMESPACE barman-plugin-backup-restore diff --git a/charts/cluster/test/barman-plugin-migration/00-minio_cleanup-assert.yaml b/charts/cluster/test/barman-plugin-migration/00-minio_cleanup-assert.yaml new file mode 100644 index 0000000000..9c0f3eb480 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/00-minio_cleanup-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: minio-cleanup +status: + succeeded: 1 diff --git a/charts/cluster/test/barman-plugin-migration/00-minio_cleanup.yaml b/charts/cluster/test/barman-plugin-migration/00-minio_cleanup.yaml new file mode 100644 index 0000000000..92b77ba8c6 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/00-minio_cleanup.yaml @@ -0,0 +1,16 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: minio-cleanup +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: minio-cleanup + image: minio/mc + command: ['sh', '-c'] + args: + - | + mc alias set myminio https://minio.minio.svc.cluster.local minio minio123 + mc rm --recursive --force myminio/mybucket/barman-plugin-migration diff --git a/charts/cluster/test/barman-plugin-migration/01-barman-plugin-migration_cluster-assert.yaml b/charts/cluster/test/barman-plugin-migration/01-barman-plugin-migration_cluster-assert.yaml new file mode 100644 index 0000000000..2475d88f6c --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/01-barman-plugin-migration_cluster-assert.yaml @@ -0,0 +1,7 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: barman-plugin-migration-cluster +status: + readyInstances: 2 + phase: Cluster in healthy state diff --git a/charts/cluster/test/barman-plugin-migration/01-barman-plugin-migration_cluster.yaml b/charts/cluster/test/barman-plugin-migration/01-barman-plugin-migration_cluster.yaml new file mode 100644 index 0000000000..738dbb8767 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/01-barman-plugin-migration_cluster.yaml @@ -0,0 +1,27 @@ +type: postgresql +mode: standalone +cluster: + instances: 2 + storage: + size: 256Mi + +backups: + enabled: true + method: barmanObjectStore + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/barman-plugin-migration/v1" + accessKey: "minio" + secretKey: "minio123" + region: "local" + scheduledBackups: [] + retentionPolicy: "30d" diff --git a/charts/cluster/test/barman-plugin-migration/02-backup.yaml b/charts/cluster/test/barman-plugin-migration/02-backup.yaml new file mode 100644 index 0000000000..8f6a692ab3 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/02-backup.yaml @@ -0,0 +1,7 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +metadata: + name: post-init-backup +spec: + cluster: + name: barman-plugin-migration-cluster diff --git a/charts/cluster/test/barman-plugin-migration/02-backup_completed-assert.yaml b/charts/cluster/test/barman-plugin-migration/02-backup_completed-assert.yaml new file mode 100644 index 0000000000..1ffe611eeb --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/02-backup_completed-assert.yaml @@ -0,0 +1,9 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +metadata: + name: post-init-backup +spec: + cluster: + name: barman-plugin-migration-cluster +status: + phase: completed diff --git a/charts/cluster/test/barman-plugin-migration/02-checkpoint.yaml b/charts/cluster/test/barman-plugin-migration/02-checkpoint.yaml new file mode 100644 index 0000000000..e740f9f831 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/02-checkpoint.yaml @@ -0,0 +1,27 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: backup-checkpoint +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: create-checkpoint + env: + - name: DB_URI + valueFrom: + secretKeyRef: + name: barman-plugin-migration-cluster-superuser + key: uri + image: alpine:3.19 + command: ['sh', '-c'] + args: + - | + apk --no-cache add postgresql-client + DB_URI=$(echo $DB_URI | sed "s|/\*|/|" ) + END_TIME=$(( $(date +%s) + 30 )) + while [ $(date +%s) -lt $END_TIME ]; do + psql "$DB_URI" -c "SELECT pg_switch_wal();CHECKPOINT;" + sleep 5 + done diff --git a/charts/cluster/test/barman-plugin-migration/03-data_write-assert.yaml b/charts/cluster/test/barman-plugin-migration/03-data_write-assert.yaml new file mode 100644 index 0000000000..831f963d9d --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/03-data_write-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-write +status: + succeeded: 1 diff --git a/charts/cluster/test/barman-plugin-migration/03-data_write.yaml b/charts/cluster/test/barman-plugin-migration/03-data_write.yaml new file mode 100644 index 0000000000..d8ff354d49 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/03-data_write.yaml @@ -0,0 +1,54 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: configmap-creator-sa +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: configmap-creator +rules: +- apiGroups: [""] + resources: ["configmaps"] + verbs: ["create"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: configmap-creator-binding +subjects: +- kind: ServiceAccount + name: configmap-creator-sa +roleRef: + kind: Role + name: configmap-creator + apiGroup: rbac.authorization.k8s.io +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: data-write +spec: + template: + spec: + serviceAccountName: configmap-creator-sa + restartPolicy: OnFailure + containers: + - name: data-write + env: + - name: DB_URI + valueFrom: + secretKeyRef: + name: barman-plugin-migration-cluster-superuser + key: uri + image: alpine:3.19 + command: ['sh', '-c'] + args: + - | + apk --no-cache add postgresql-client kubectl coreutils + DB_URI=$(echo $DB_URI | sed "s|/\*|/|" ) + psql "$DB_URI" -c "CREATE TABLE mygoodtable (id serial PRIMARY KEY);" + sleep 5 + DATE_NO_BAD_TABLE=$(date --rfc-3339=ns) + kubectl create configmap date-no-bad-table --from-literal=date="$DATE_NO_BAD_TABLE" + sleep 5 diff --git a/charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster-assert.yaml b/charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster-assert.yaml new file mode 100644 index 0000000000..7aed154fc2 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster-assert.yaml @@ -0,0 +1,12 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: barman-plugin-migration-cluster +status: + readyInstances: 2 + phase: Cluster in healthy state +--- +apiVersion: barmancloud.cnpg.io/v1 +kind: ObjectStore +metadata: + name: barman-plugin-migration-cluster-backups diff --git a/charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster.yaml b/charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster.yaml new file mode 100644 index 0000000000..9abd52993e --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster.yaml @@ -0,0 +1,31 @@ +type: postgresql +mode: standalone +cluster: + instances: 2 + storage: + size: 256Mi + plugins: + - name: barman-cloud.cloudnative-pg.io + enabled: true + isWALArchiver: true + +backups: + enabled: true + method: barmanObjectStore + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/barman-plugin-migration/v1" + accessKey: "minio" + secretKey: "minio123" + region: "local" + scheduledBackups: [] + retentionPolicy: "30d" diff --git a/charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster-assert.yaml b/charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster-assert.yaml new file mode 100644 index 0000000000..27991bd3c8 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster-assert.yaml @@ -0,0 +1,17 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: barman-plugin-migration-cluster +status: + readyInstances: 2 + phase: Cluster in healthy state +spec: + plugins: + - name: barman-cloud.cloudnative-pg.io + enabled: true + isWALArchiver: true +--- +apiVersion: barmancloud.cnpg.io/v1 +kind: ObjectStore +metadata: + name: barman-plugin-migration-cluster-backups diff --git a/charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster.yaml b/charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster.yaml new file mode 100644 index 0000000000..9ecad0b1a7 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster.yaml @@ -0,0 +1,31 @@ +type: postgresql +mode: standalone +cluster: + instances: 2 + storage: + size: 256Mi + plugins: + - name: barman-cloud.cloudnative-pg.io + enabled: true + isWALArchiver: true + +backups: + enabled: true + method: plugin + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/barman-plugin-migration/v1" + accessKey: "minio" + secretKey: "minio123" + region: "local" + scheduledBackups: [] + retentionPolicy: "30d" diff --git a/charts/cluster/test/barman-plugin-migration/05-backup.yaml b/charts/cluster/test/barman-plugin-migration/05-backup.yaml new file mode 100644 index 0000000000..dc17c75f2b --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/05-backup.yaml @@ -0,0 +1,10 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +metadata: + name: post-migrate-backup +spec: + cluster: + name: barman-plugin-migration-cluster + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io diff --git a/charts/cluster/test/barman-plugin-migration/05-backup_completed-assert.yaml b/charts/cluster/test/barman-plugin-migration/05-backup_completed-assert.yaml new file mode 100644 index 0000000000..12a99f2470 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/05-backup_completed-assert.yaml @@ -0,0 +1,12 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +metadata: + name: post-migrate-backup +spec: + cluster: + name: barman-plugin-migration-cluster + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io +status: + phase: completed diff --git a/charts/cluster/test/barman-plugin-migration/05-backup_running-assert.yaml b/charts/cluster/test/barman-plugin-migration/05-backup_running-assert.yaml new file mode 100644 index 0000000000..c1fa64a4c1 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/05-backup_running-assert.yaml @@ -0,0 +1,12 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +metadata: + name: post-migrate-backup +spec: + cluster: + name: barman-plugin-migration-cluster + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io +status: + phase: running diff --git a/charts/cluster/test/barman-plugin-migration/05-checkpoint.yaml b/charts/cluster/test/barman-plugin-migration/05-checkpoint.yaml new file mode 100644 index 0000000000..1374e993c4 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/05-checkpoint.yaml @@ -0,0 +1,27 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: post-migrate-backup-checkpoint +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: create-checkpoint + env: + - name: DB_URI + valueFrom: + secretKeyRef: + name: barman-plugin-migration-cluster-superuser + key: uri + image: alpine:3.19 + command: ['sh', '-c'] + args: + - | + apk --no-cache add postgresql-client + DB_URI=$(echo $DB_URI | sed "s|/\*|/|" ) + END_TIME=$(( $(date +%s) + 30 )) + while [ $(date +%s) -lt $END_TIME ]; do + psql "$DB_URI" -c "SELECT pg_switch_wal();CHECKPOINT;" + sleep 5 + done diff --git a/charts/cluster/test/barman-plugin-migration/06-post_backup_data_write-assert.yaml b/charts/cluster/test/barman-plugin-migration/06-post_backup_data_write-assert.yaml new file mode 100644 index 0000000000..ad9be77a7b --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/06-post_backup_data_write-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-write-post-backup +status: + succeeded: 1 diff --git a/charts/cluster/test/barman-plugin-migration/06-post_backup_data_write.yaml b/charts/cluster/test/barman-plugin-migration/06-post_backup_data_write.yaml new file mode 100644 index 0000000000..87d1a33637 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/06-post_backup_data_write.yaml @@ -0,0 +1,27 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-write-post-backup +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: data-write + env: + - name: DB_URI + valueFrom: + secretKeyRef: + name: barman-plugin-migration-cluster-superuser + key: uri + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + image: alpine:3.19 + command: ['sh', '-c'] + args: + - | + apk --no-cache add postgresql-client + DB_URI=$(echo $DB_URI | sed "s|/\*|/|" ) + psql "$DB_URI" -c "CREATE TABLE mybadtable (id serial PRIMARY KEY);" diff --git a/charts/cluster/test/barman-plugin-migration/07-recovery_backup_pitr_cluster-assert.yaml b/charts/cluster/test/barman-plugin-migration/07-recovery_backup_pitr_cluster-assert.yaml new file mode 100644 index 0000000000..2b6b9651f1 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/07-recovery_backup_pitr_cluster-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: recovery-backup-pitr-cluster +status: + readyInstances: 2 diff --git a/charts/cluster/test/barman-plugin-migration/07-recovery_backup_pitr_cluster.yaml b/charts/cluster/test/barman-plugin-migration/07-recovery_backup_pitr_cluster.yaml new file mode 100644 index 0000000000..55ccb69dd7 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/07-recovery_backup_pitr_cluster.yaml @@ -0,0 +1,50 @@ +type: postgresql +mode: recovery + +cluster: + instances: 2 + storage: + size: 256Mi + +recovery: + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/barman-plugin-migration/v1" + accessKey: "minio" + secretKey: "minio123" + region: "local" + clusterName: "barman-plugin-migration-cluster" + retentionPolicy: "30d" + scheduledBackups: [] + +backups: + enabled: true + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/barman-plugin-migration/v2" + accessKey: "minio" + secretKey: "minio123" + region: "local" + scheduledBackups: [] + retentionPolicy: "30d" diff --git a/charts/cluster/test/barman-plugin-migration/08-data_test-assert.yaml b/charts/cluster/test/barman-plugin-migration/08-data_test-assert.yaml new file mode 100644 index 0000000000..6f14d5f231 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/08-data_test-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-test-backup-pitr +status: + succeeded: 1 diff --git a/charts/cluster/test/barman-plugin-migration/08-data_test.yaml b/charts/cluster/test/barman-plugin-migration/08-data_test.yaml new file mode 100644 index 0000000000..694a7ba252 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/08-data_test.yaml @@ -0,0 +1,27 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-test-backup-pitr +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: data-test + env: + - name: DB_URI + valueFrom: + secretKeyRef: + name: recovery-backup-pitr-superuser + key: uri + image: alpine:3.19 + command: ['sh', '-c'] + args: + - | + apk --no-cache add postgresql-client + DB_URI=$(echo $DB_URI | sed "s|/\*|/|" ) + set -e + test "$(psql $DB_URI -t -c 'SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = $$mygoodtable$$)' --csv -q 2>/dev/null)" = "t" + echo "Good table exists" + test "$(psql $DB_URI -t -c 'SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = $$mybadtable$$)' --csv -q 2>/dev/null)" = "f" + echo "Bad table does not exist" diff --git a/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml new file mode 100644 index 0000000000..71bfe56249 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml @@ -0,0 +1,173 @@ +## +# This test sets up a CNPG Cluster with MinIO backups and test that it can be migrated to the Barman Cloud CNPG-I plugin +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + name: barman-plugin-migration +spec: + timeouts: + apply: 1s + assert: 7m + cleanup: 1m + steps: + - name: Clear the MinIO bucket + try: + - apply: + file: ./00-minio_cleanup.yaml + - assert: + file: ./00-minio_cleanup-assert.yaml + - name: Install a standalone CNPG Cluster + try: + - script: + content: | + kubectl -n $NAMESPACE create secret generic kube-root-ca.crt --from-literal=ca.crt="$(kubectl -n kube-system get configmaps kube-root-ca.crt -o jsonpath='{.data.ca\.crt}')" --dry-run=client -o yaml | kubectl apply -f - + helm upgrade \ + --install \ + --namespace $NAMESPACE \ + --values ./01-barman-plugin-migration_cluster.yaml \ + --wait \ + barman-plugin-migration ../../ + - assert: + file: ./01-barman-plugin-migration_cluster-assert.yaml + catch: + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Cluster + - podLogs: + selector: cnpg.io/cluster=barman-plugin-migration-cluster + - name: Create a backup + try: + - apply: + file: ./02-backup.yaml + - apply: + file: ./02-checkpoint.yaml + - assert: + file: ./02-backup_completed-assert.yaml + catch: + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Backup + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Cluster + - podLogs: + selector: cnpg.io/cluster=barman-plugin-backup-restore-cluster + - name: Write some data to the cluster + timeouts: + apply: 1s + assert: 30s + try: + - apply: + file: 03-data_write.yaml + - assert: + file: 03-data_write-assert.yaml + catch: + - describe: + apiVersion: batch/v1 + kind: Job + - podLogs: + selector: batch.kubernetes.io/job-name=data-write + - name: Switch the cluster to using Barman CNPG-I for backups + try: + - script: + content: | + kubectl -n $NAMESPACE create secret generic kube-root-ca.crt --from-literal=ca.crt="$(kubectl -n kube-system get configmaps kube-root-ca.crt -o jsonpath='{.data.ca\.crt}')" --dry-run=client -o yaml | kubectl apply -f - + helm upgrade \ + --namespace $NAMESPACE \ + --values ./04.1-barman-plugin-migration_cluster.yaml \ + --wait \ + barman-plugin-migration ../../ + - assert: + file: ./04.1-barman-plugin-migration_cluster-assert.yaml + - script: + content: | + helm upgrade \ + --namespace $NAMESPACE \ + --values ./04.2-barman-plugin-migration_cluster.yaml \ + --wait \ + barman-plugin-migration ../../ + - script: + content: sleep 1 + - assert: + file: ./04.2-barman-plugin-migration_cluster-assert.yaml + - name: Create a buckup with the Barman CNPG-I plugin + try: + - apply: + file: ./05-backup.yaml + - assert: + file: ./05-backup_running-assert.yaml + catch: + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Backup + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Cluster + - podLogs: + selector: cnpg.io/cluster=barman-plugin-migration-cluster + - name: Complete a backup + try: + - apply: + file: ./05-checkpoint.yaml + - assert: + file: ./05-backup_completed-assert.yaml + catch: + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Backup + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Cluster + - podLogs: + selector: cnpg.io/cluster=barman-plugin-migration-cluster + - name: Write more data to the database after the backup + try: + - apply: + file: ./06-post_backup_data_write.yaml + - assert: + file: ./06-post_backup_data_write-assert.yaml + timeouts: + apply: 1s + assert: 10m + catch: + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Backup + - name: Create a recovery cluster from backup with a PITR target + try: + - script: + content: | + DATE_NO_BAD_TABLE=$(kubectl -n $NAMESPACE get configmap date-no-bad-table -o 'jsonpath={.data.date}') + helm upgrade \ + --install \ + --namespace $NAMESPACE \ + --values ./07-recovery_backup_pitr_cluster.yaml \ + --set recovery.pitrTarget.time="$DATE_NO_BAD_TABLE" \ + --wait \ + recovery-backup-pitr ../../ + - assert: + file: ./07-recovery_backup_pitr_cluster-assert.yaml + catch: + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Cluster + - podLogs: + selector: cnpg.io/cluster=recovery-backup-pitr-cluster + - name: Verify the pre-backup data on the recovery cluster exists but not the post-backup data + try: + - apply: + file: ./08-data_test.yaml + - assert: + file: ./08-data_test-assert.yaml + catch: + - describe: + apiVersion: batch/v1 + kind: Job + selector: batch.kubernetes.io/job-name=data-test-backup-pitr + - podLogs: + selector: batch.kubernetes.io/job-name=data-test-backup-pitr + - name: Cleanup + try: + - script: + content: | + helm uninstall --namespace $NAMESPACE barman-plugin-migration diff --git a/charts/cluster/test/barman-plugin-scheduledbackups/00-minio_cleanup-assert.yaml b/charts/cluster/test/barman-plugin-scheduledbackups/00-minio_cleanup-assert.yaml new file mode 100644 index 0000000000..9c0f3eb480 --- /dev/null +++ b/charts/cluster/test/barman-plugin-scheduledbackups/00-minio_cleanup-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: minio-cleanup +status: + succeeded: 1 diff --git a/charts/cluster/test/barman-plugin-scheduledbackups/00-minio_cleanup.yaml b/charts/cluster/test/barman-plugin-scheduledbackups/00-minio_cleanup.yaml new file mode 100644 index 0000000000..7ee8bc0340 --- /dev/null +++ b/charts/cluster/test/barman-plugin-scheduledbackups/00-minio_cleanup.yaml @@ -0,0 +1,16 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: minio-cleanup +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: minio-cleanup + image: minio/mc + command: ['sh', '-c'] + args: + - | + mc alias set myminio https://minio.minio.svc.cluster.local minio minio123 + mc rm --recursive --force myminio/mybucket/barman-plugin-scheduledbackups diff --git a/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster-assert.yaml b/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster-assert.yaml new file mode 100644 index 0000000000..6b7e523655 --- /dev/null +++ b/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster-assert.yaml @@ -0,0 +1,62 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: scheduledbackups-cluster +status: + readyInstances: 1 +--- +apiVersion: barmancloud.cnpg.io/v1 +kind: ObjectStore +metadata: + name: scheduledbackups-cluster-backups +spec: + retentionPolicy: 30d + configuration: + destinationPath: s3://mybucket/barman-plugin-scheduledbackups/v1 + endpointCA: + key: ca.crt + name: kube-root-ca.crt + endpointURL: https://minio.minio.svc.cluster.local + s3Credentials: + accessKeyId: + key: ACCESS_KEY_ID + name: scheduledbackups-cluster-backup-s3-creds + secretAccessKey: + key: ACCESS_SECRET_KEY + name: scheduledbackups-cluster-backup-s3-creds +--- +apiVersion: postgresql.cnpg.io/v1 +kind: ScheduledBackup +metadata: + name: scheduledbackups-cluster-daily-backup +spec: + immediate: true + schedule: "0 0 0 * * *" + method: plugin + backupOwnerReference: self + cluster: + name: scheduledbackups-cluster +--- +apiVersion: postgresql.cnpg.io/v1 +kind: ScheduledBackup +metadata: + name: scheduledbackups-cluster-weekly-backup +spec: + immediate: true + schedule: "0 0 0 * * 1" + method: plugin + backupOwnerReference: self + cluster: + name: scheduledbackups-cluster + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io +--- +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +spec: + method: plugin + cluster: + name: scheduledbackups-cluster + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io +status: diff --git a/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml b/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml new file mode 100644 index 0000000000..2cdb63446b --- /dev/null +++ b/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml @@ -0,0 +1,43 @@ +type: postgresql +mode: standalone +cluster: + instances: 1 + storage: + size: 256Mi + plugins: + - name: barman-cloud.cloudnative-pg.io + enabled: true + isWALArchiver: true + +backups: + enabled: true + method: plugin + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/barman-plugin-scheduledbackups/v1" + accessKey: "minio" + secretKey: "minio123" + region: "local" + retentionPolicy: "30d" + scheduledBackups: + - name: daily-backup + schedule: "0 0 0 * * *" + backupOwnerReference: self + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io + - name: weekly-backup + schedule: "0 0 0 * * 1" + backupOwnerReference: self + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io diff --git a/charts/cluster/test/barman-plugin-scheduledbackups/01.1-checkpoint.yaml b/charts/cluster/test/barman-plugin-scheduledbackups/01.1-checkpoint.yaml new file mode 100644 index 0000000000..6770a95c95 --- /dev/null +++ b/charts/cluster/test/barman-plugin-scheduledbackups/01.1-checkpoint.yaml @@ -0,0 +1,27 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: scheduledbackups-cluster-checkpoint +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: create-checkpoint + env: + - name: DB_URI + valueFrom: + secretKeyRef: + name: scheduledbackups-cluster-superuser + key: uri + image: alpine:3.19 + command: ['sh', '-c'] + args: + - | + apk --no-cache add postgresql-client + DB_URI=$(echo $DB_URI | sed "s|/\*|/|" ) + END_TIME=$(( $(date +%s) + 30 )) + while [ $(date +%s) -lt $END_TIME ]; do + psql "$DB_URI" -c "SELECT pg_switch_wal();CHECKPOINT;" + sleep 5 + done diff --git a/charts/cluster/test/barman-plugin-scheduledbackups/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-scheduledbackups/chainsaw-test.yaml new file mode 100644 index 0000000000..7a29e05cc3 --- /dev/null +++ b/charts/cluster/test/barman-plugin-scheduledbackups/chainsaw-test.yaml @@ -0,0 +1,31 @@ +# Tests the Barman Cloud CNPG-I Plugin with ScheduledBackups +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + name: barman-plugin-scheduledbackups +spec: + timeouts: + apply: 1s + assert: 2m + cleanup: 5m + steps: + - name: Install the cluster with ScheduledBackups + try: + - script: + content: | + kubectl -n $NAMESPACE create secret generic kube-root-ca.crt --from-literal=ca.crt="$(kubectl -n kube-system get configmaps kube-root-ca.crt -o jsonpath='{.data.ca\.crt}')" --dry-run=client -o yaml | kubectl apply -f - + helm upgrade \ + --install \ + --namespace $NAMESPACE \ + --values ./01-scheduledbackups_cluster.yaml \ + --wait \ + scheduledbackups ../../ + - assert: + file: ./01-scheduledbackups_cluster-assert.yaml + - apply: + file: ./01.1-checkpoint.yaml + - name: Cleanup + try: + - script: + content: | + helm uninstall --namespace $NAMESPACE scheduledbackups From 089abe9bd2ead66d16c33cc4d95cf5801eb56dac Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Sat, 20 Jun 2026 15:23:58 +0300 Subject: [PATCH 06/43] fix: recovery plugin cluster external cluster configuration Signed-off-by: Itay Grudev --- charts/cluster/templates/_external_clusters.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/cluster/templates/_external_clusters.tpl b/charts/cluster/templates/_external_clusters.tpl index cd221620fe..dc86484716 100644 --- a/charts/cluster/templates/_external_clusters.tpl +++ b/charts/cluster/templates/_external_clusters.tpl @@ -17,12 +17,12 @@ externalClusters: serverName: {{ .Values.recovery.clusterName }} {{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.recovery "secretPrefix" "recovery" -}} {{- include "cluster.barmanObjectStoreConfig" $d | nindent 4 }} - {{- else if eq .Values.recovery.method "plugin" }} + {{- else if and (eq .Values.recovery.method "plugin") (eq .Values.recovery.pluginConfiguration.name "barman-cloud.cloudnative-pg.io") }} - name: pluginRecoveryCluster plugin: {{- omit .Values.recovery.pluginConfiguration "parameters" | toYaml | nindent 6 }} parameters: - {{- $pluginConfigurationParameters := omit (coalesce .Values.recovery.pluginConfiguration.parameters dict) "barmanObjectName" -}} + {{- $pluginConfigurationParameters := omit (coalesce .Values.recovery.pluginConfiguration.parameters dict) "barmanObjectName" "serverName" -}} {{ with $pluginConfigurationParameters }} {{- toYaml . | nindent 8 -}} {{ end }} From 03d0f2cccddb0fe5fe2ee607ae1e36f414a02789 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Sat, 20 Jun 2026 15:29:55 +0300 Subject: [PATCH 07/43] fix incorrect schema Signed-off-by: Itay Grudev --- charts/cluster/README.md | 2 +- .../05-recovery_backup_pitr_cluster.yaml | 31 +++++++++---------- charts/cluster/values.schema.json | 4 +-- charts/cluster/values.yaml | 2 +- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/charts/cluster/README.md b/charts/cluster/README.md index 042414e8d5..f250742e99 100644 --- a/charts/cluster/README.md +++ b/charts/cluster/README.md @@ -281,7 +281,7 @@ Kubernetes: `>=1.29.0-0` | recovery.pgBaseBackup.source.username | string | `""` | | | recovery.pitrTarget | object | `{"time":""}` | Point in time recovery target. Specify one of the following: | | recovery.pitrTarget.time | string | `""` | Time in RFC3339 format | -| recovery.pluginConfiguration | string | `nil` | | +| recovery.pluginConfiguration | object | `{}` | | | recovery.provider | string | `"s3"` | One of `s3`, `azure` or `google` | | recovery.s3.accessKey | string | `""` | | | recovery.s3.bucket | string | `""` | | diff --git a/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml b/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml index a138ec0c2d..e0c634c26f 100644 --- a/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml +++ b/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml @@ -36,21 +36,20 @@ recovery: backups: enabled: true method: plugin - barmanObjectStore: - provider: s3 - endpointURL: "https://minio.minio.svc.cluster.local" - endpointCA: - name: kube-root-ca.crt - key: ca.crt - wal: - encryption: "" - data: - encryption: "" - s3: - bucket: "mybucket" - path: "/barman-plugin-backup-restore/v2" - accessKey: "minio" - secretKey: "minio123" - region: "local" + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/barman-plugin-backup-restore/v2" + accessKey: "minio" + secretKey: "minio123" + region: "local" scheduledBackups: [] retentionPolicy: "30d" diff --git a/charts/cluster/values.schema.json b/charts/cluster/values.schema.json index 789d67421d..efa77112f7 100644 --- a/charts/cluster/values.schema.json +++ b/charts/cluster/values.schema.json @@ -1062,8 +1062,8 @@ "type": "object" }, "pluginConfiguration": { - "default": "", - "type": "null" + "required": [], + "type": "object" }, "provider": { "default": "s3", diff --git a/charts/cluster/values.yaml b/charts/cluster/values.yaml index 81b16ae241..90975da65a 100644 --- a/charts/cluster/values.yaml +++ b/charts/cluster/values.yaml @@ -50,7 +50,7 @@ recovery: # -- Name of the owner of the database in the instance to be used by applications. Defaults to the value of the `database` key. owner: "" - pluginConfiguration: + pluginConfiguration: {} #name: barman-cloud.cloudnative-pg.io #parameters: # serverName: cluster-example From 58fe5ccccedfbb73b7390c5ac2990718aa6a8847 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Sat, 20 Jun 2026 15:33:33 +0300 Subject: [PATCH 08/43] fix: scheduled backups test - match only the immediate daily test Signed-off-by: Itay Grudev --- .../01-scheduledbackups_cluster-assert.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster-assert.yaml b/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster-assert.yaml index 6b7e523655..cac56a54ac 100644 --- a/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster-assert.yaml +++ b/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster-assert.yaml @@ -53,6 +53,11 @@ spec: --- apiVersion: postgresql.cnpg.io/v1 kind: Backup +metadata: + ownerReferences: + - apiVersion: postgresql.cnpg.io/v1 + kind: ScheduledBackup + name: scheduledbackups-cluster-daily-backup spec: method: plugin cluster: @@ -60,3 +65,4 @@ spec: pluginConfiguration: name: barman-cloud.cloudnative-pg.io status: + phase: started From e1175c95058b598b43b011ad17850339bb5b1e83 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Sat, 20 Jun 2026 15:35:55 +0300 Subject: [PATCH 09/43] test: incorrect cluster iname in barman-plugin-backup-restore test Signed-off-by: Itay Grudev --- .../05-recovery_backup_pitr_cluster.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml b/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml index e0c634c26f..45b23c4407 100644 --- a/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml +++ b/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml @@ -29,7 +29,7 @@ recovery: accessKey: "minio" secretKey: "minio123" region: "local" - clusterName: "barman-plugin-backup-restore" + clusterName: "barman-plugin-backup-restore-cluster" retentionPolicy: "30d" scheduledBackups: [] From f7c749672f5bb07134b703a3ddc08d599e4a592c Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Sat, 20 Jun 2026 15:48:45 +0300 Subject: [PATCH 10/43] fix lint Signed-off-by: Itay Grudev --- charts/cluster/README.md | 1 + charts/cluster/values.schema.json | 4 ++++ charts/cluster/values.yaml | 10 +++++----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/charts/cluster/README.md b/charts/cluster/README.md index f250742e99..b3e61c4ecd 100644 --- a/charts/cluster/README.md +++ b/charts/cluster/README.md @@ -149,6 +149,7 @@ Kubernetes: `>=1.29.0-0` | backups.scheduledBackups[0].backupOwnerReference | string | `"self"` | Backup owner reference | | backups.scheduledBackups[0].method | string | `"barmanObjectStore"` | Backup method, can be `barmanObjectStore` (default), `volumeSnapshot` or `plugin`. | | backups.scheduledBackups[0].name | string | `"daily-backup"` | Scheduled backup name | +| backups.scheduledBackups[0].pluginConfiguration | object | `{}` | | | backups.scheduledBackups[0].schedule | string | `"0 0 0 * * *"` | Schedule in cron format | | backups.secret.create | bool | `true` | Whether to create a secret for the backup credentials | | backups.secret.name | string | `""` | Name of the backup credentials secret | diff --git a/charts/cluster/values.schema.json b/charts/cluster/values.schema.json index efa77112f7..b3df291d82 100644 --- a/charts/cluster/values.schema.json +++ b/charts/cluster/values.schema.json @@ -194,6 +194,10 @@ "description": "Scheduled backup name", "type": "string" }, + "pluginConfiguration": { + "required": [], + "type": "object" + }, "schedule": { "default": "0 0 0 * * *", "description": "Schedule in cron format", diff --git a/charts/cluster/values.yaml b/charts/cluster/values.yaml index 90975da65a..42020c3fa8 100644 --- a/charts/cluster/values.yaml +++ b/charts/cluster/values.yaml @@ -51,9 +51,9 @@ recovery: owner: "" pluginConfiguration: {} - #name: barman-cloud.cloudnative-pg.io - #parameters: - # serverName: cluster-example +# name: barman-cloud.cloudnative-pg.io +# parameters: +# serverName: cluster-example # Barman Object Store configuration applicable to both `barmanObjectStore` and `plugin` methods when using # the `barman-cloud.cloudnative-pg.io` plugin. @@ -548,8 +548,8 @@ backups: backupOwnerReference: self # -- Backup method, can be `barmanObjectStore` (default), `volumeSnapshot` or `plugin`. method: barmanObjectStore - #pluginConfiguration: - # name: barman-cloud.cloudnative-pg.io + pluginConfiguration: {} +# name: barman-cloud.cloudnative-pg.io # -- Retention policy for backups retentionPolicy: "30d" From 06da8c73238c75aa633b394be2fd0306d4ab89f5 Mon Sep 17 00:00:00 2001 From: Jan Larwig Date: Wed, 24 Jun 2026 17:16:12 +0200 Subject: [PATCH 11/43] fix: plugin-barman-cloud likeness and readiness probes (#776) Signed-off-by: Nolan Gilley Signed-off-by: Jan Larwig Signed-off-by: Itay Grudev Co-authored-by: Nolan Gilley Co-authored-by: Itay Grudev --- charts/plugin-barman-cloud/templates/deployment.yaml | 7 ++++++- .../simple-deployment/01-simple_deployment-assert.yaml | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/charts/plugin-barman-cloud/templates/deployment.yaml b/charts/plugin-barman-cloud/templates/deployment.yaml index 893fdc2fc8..630113b74d 100644 --- a/charts/plugin-barman-cloud/templates/deployment.yaml +++ b/charts/plugin-barman-cloud/templates/deployment.yaml @@ -78,7 +78,12 @@ spec: initialDelaySeconds: 10 periodSeconds: 10 tcpSocket: - port: 9090 + port: 8081 + livenessProbe: + initialDelaySeconds: 10 + periodSeconds: 10 + tcpSocket: + port: 8081 resources: {{- toYaml .Values.resources | nindent 10 }} securityContext: diff --git a/charts/plugin-barman-cloud/test/simple-deployment/01-simple_deployment-assert.yaml b/charts/plugin-barman-cloud/test/simple-deployment/01-simple_deployment-assert.yaml index 37e11d27bf..961ae76fad 100644 --- a/charts/plugin-barman-cloud/test/simple-deployment/01-simple_deployment-assert.yaml +++ b/charts/plugin-barman-cloud/test/simple-deployment/01-simple_deployment-assert.yaml @@ -23,7 +23,12 @@ spec: initialDelaySeconds: 10 periodSeconds: 10 tcpSocket: - port: 9090 + port: 8081 + livenessProbe: + initialDelaySeconds: 10 + periodSeconds: 10 + tcpSocket: + port: 8081 resources: limits: cpu: 100m From ccdf1583e42bdb851879aef983aef5d75b3ee563 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 25 Jun 2026 14:25:05 +0300 Subject: [PATCH 12/43] chore(deps): update actions/setup-python action to v6.3.0 (#927) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cfa18e45b6..1eecc97e9f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -38,7 +38,7 @@ jobs: with: version: v3.21.1 - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 with: python-version: 3.14 From 4e2b126879f0d9968faac22a7ee62216dc78570e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 25 Jun 2026 15:31:46 +0300 Subject: [PATCH 13/43] chore(deps): update azure/setup-helm action to v5.0.1 (#926) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Itay Grudev --- .github/actions/setup-kind/action.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/release-publish.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/setup-kind/action.yml b/.github/actions/setup-kind/action.yml index 709b28afd8..e81c2c2707 100644 --- a/.github/actions/setup-kind/action.yml +++ b/.github/actions/setup-kind/action.yml @@ -12,7 +12,7 @@ runs: steps: - id: helm name: Set up Helm - uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0 + uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1 with: version: v3.21.1 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1eecc97e9f..bc4d80869b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -34,7 +34,7 @@ jobs: fetch-depth: 0 - name: Set up Helm - uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0 + uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1 with: version: v3.21.1 diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index 8ad8e878e0..6e72411ffe 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -34,7 +34,7 @@ jobs: echo "${{ secrets.PGP_KEY_PASSPHRASE }}" > /tmp/passphrase-file.txt - name: Set up Helm - uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0 + uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1 with: version: v3.21.1 From fe2a74a06c7e805f029eefbb9887460054ce3658 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Thu, 25 Jun 2026 23:40:53 +0300 Subject: [PATCH 14/43] fix: when is the main plugins section specified Signed-off-by: Itay Grudev --- charts/cluster/templates/cluster.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/charts/cluster/templates/cluster.yaml b/charts/cluster/templates/cluster.yaml index c2b0d98e88..dcc164b93b 100644 --- a/charts/cluster/templates/cluster.yaml +++ b/charts/cluster/templates/cluster.yaml @@ -153,16 +153,15 @@ spec: {{ include "cluster.externalClusters" . | nindent 2 -}} {{ include "cluster.backup" . | nindent 2 -}} - {{- $plugins := len .Values.cluster.plugins -}} - {{- if and (gt $plugins 0) (or (gt $plugins 1) (and .Values.backups.enabled (eq (include "cluster.barmanPluginEnabled" .) "true") (eq .Values.backups.method "plugin"))) }} + {{- if gt (len .Values.cluster.plugins) 0 }} plugins: {{ $pluginsWithoutBarman := include "helpers.omitKeyValue" (list .Values.cluster.plugins (list (list "name" "barman-cloud.cloudnative-pg.io"))) | fromYamlArray }} {{- range $pluginsWithoutBarman -}} - {{ toYaml . | indent 6 | trim }} {{- end }} - {{- if and .Values.backups.enabled (eq (include "cluster.barmanPluginEnabled" .) "true") (eq .Values.backups.method "plugin") }} + {{- if and (eq (include "cluster.barmanPluginEnabled" .) "true") (and .Values.backups.enabled (eq .Values.backups.method "plugin") (eq .Values.backups.pluginConfiguration.name "barman-cloud.cloudnative-pg.io")) }} {{- $barmanPlugin := include "helpers.fetchKeyValue" (list .Values.cluster.plugins (list (list "name" "barman-cloud.cloudnative-pg.io"))) | fromYaml -}} - - name: {{ $barmanPlugin.name }} + - name: barman-cloud.cloudnative-pg.io enabled: true isWALArchiver: true parameters: From 042e216478763e6bb95a1b95c88801ea30104253 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Thu, 25 Jun 2026 23:43:48 +0300 Subject: [PATCH 15/43] explicitly specifying backup pluginConfiguration Signed-off-by: Itay Grudev --- charts/cluster/README.md | 1 + charts/cluster/templates/backup-objectstore.yaml | 1 - charts/cluster/templates/recovery-objectstore.yaml | 1 - .../01-barman-plugin-backup-restore_cluster.yaml | 2 ++ .../05-recovery_backup_pitr_cluster.yaml | 12 +++++------- .../04.2-barman-plugin-migration_cluster.yaml | 2 ++ .../01-scheduledbackups_cluster.yaml | 2 ++ charts/cluster/values.schema.json | 4 ++++ charts/cluster/values.yaml | 3 +++ 9 files changed, 19 insertions(+), 9 deletions(-) diff --git a/charts/cluster/README.md b/charts/cluster/README.md index b3e61c4ecd..f0374394cc 100644 --- a/charts/cluster/README.md +++ b/charts/cluster/README.md @@ -138,6 +138,7 @@ Kubernetes: `>=1.29.0-0` | backups.google.path | string | `"/"` | | | backups.instanceSidecarConfiguration | object | `{}` | The configuration for the Barman Cloud Plugin sidecar that runs in the instance pods. See: https://cloudnative-pg.io/plugin-barman-cloud/docs/next/plugin-barman-cloud.v1/#instancesidecarconfiguration | | backups.method | string | `"barmanObjectStore"` | One of `barmanObjectStore` (default) or `plugin` | +| backups.pluginConfiguration | object | `{}` | | | backups.provider | string | `"s3"` | One of `s3`, `azure` or `google` | | backups.retentionPolicy | string | `"30d"` | Retention policy for backups | | backups.s3.accessKey | string | `""` | | diff --git a/charts/cluster/templates/backup-objectstore.yaml b/charts/cluster/templates/backup-objectstore.yaml index 0c23c12c25..27bf5bf219 100644 --- a/charts/cluster/templates/backup-objectstore.yaml +++ b/charts/cluster/templates/backup-objectstore.yaml @@ -28,7 +28,6 @@ spec: encryption: {{ .Values.backups.data.encryption }} {{- end }} jobs: {{ .Values.backups.data.jobs }} - {{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.backups "secretPrefix" "backup" }} {{- include "cluster.barmanObjectStoreConfig" $d | nindent 2 }} instanceSidecarConfiguration: diff --git a/charts/cluster/templates/recovery-objectstore.yaml b/charts/cluster/templates/recovery-objectstore.yaml index 8ae69b967e..b56902d99f 100644 --- a/charts/cluster/templates/recovery-objectstore.yaml +++ b/charts/cluster/templates/recovery-objectstore.yaml @@ -17,7 +17,6 @@ spec: configuration: {{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.recovery "secretPrefix" "recovery" -}} {{- include "cluster.barmanObjectStoreConfig" $d | indent 2 }} - retentionPolicy: {{ .Values.recovery.retentionPolicy }} instanceSidecarConfiguration: {{- .Values.recovery.instanceSidecarConfiguration | toYaml | nindent 4 }} {{- end }} diff --git a/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster.yaml b/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster.yaml index 22735eee56..13f8220843 100644 --- a/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster.yaml +++ b/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster.yaml @@ -12,6 +12,8 @@ cluster: backups: enabled: true method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io provider: s3 endpointURL: "https://minio.minio.svc.cluster.local" endpointCA: diff --git a/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml b/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml index 45b23c4407..d32fc02a4d 100644 --- a/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml +++ b/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml @@ -5,15 +5,12 @@ cluster: instances: 2 storage: size: 256Mi - plugins: - - name: barman-cloud.cloudnative-pg.io - enabled: true - isWALArchiver: true recovery: method: plugin pluginConfiguration: name: barman-cloud.cloudnative-pg.io + clusterName: "barman-plugin-backup-restore-cluster" provider: s3 endpointURL: "https://minio.minio.svc.cluster.local" endpointCA: @@ -29,13 +26,14 @@ recovery: accessKey: "minio" secretKey: "minio123" region: "local" - clusterName: "barman-plugin-backup-restore-cluster" - retentionPolicy: "30d" scheduledBackups: [] + retentionPolicy: "30d" backups: - enabled: true + enabled: false method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io provider: s3 endpointURL: "https://minio.minio.svc.cluster.local" endpointCA: diff --git a/charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster.yaml b/charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster.yaml index 9ecad0b1a7..742ff648ca 100644 --- a/charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster.yaml +++ b/charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster.yaml @@ -12,6 +12,8 @@ cluster: backups: enabled: true method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io provider: s3 endpointURL: "https://minio.minio.svc.cluster.local" endpointCA: diff --git a/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml b/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml index 2cdb63446b..f46c3e282f 100644 --- a/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml +++ b/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml @@ -12,6 +12,8 @@ cluster: backups: enabled: true method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io provider: s3 endpointURL: "https://minio.minio.svc.cluster.local" endpointCA: diff --git a/charts/cluster/values.schema.json b/charts/cluster/values.schema.json index b3df291d82..29c5acb352 100644 --- a/charts/cluster/values.schema.json +++ b/charts/cluster/values.schema.json @@ -133,6 +133,10 @@ "description": "One of `barmanObjectStore` (default) or `plugin`", "type": "string" }, + "pluginConfiguration": { + "required": [], + "type": "object" + }, "provider": { "default": "s3", "description": "One of `s3`, `azure` or `google`", diff --git a/charts/cluster/values.yaml b/charts/cluster/values.yaml index 42020c3fa8..1f570d603d 100644 --- a/charts/cluster/values.yaml +++ b/charts/cluster/values.yaml @@ -466,6 +466,9 @@ backups: # -- One of `barmanObjectStore` (default) or `plugin` method: barmanObjectStore + pluginConfiguration: {} +# name: barman-cloud.cloudnative-pg.io + # Barman Object Store configuration applicable to both `barmanObjectStore` and `plugin` methods when using # the `barman-cloud.cloudnative-pg.io` plugin. From 9b8ac18b72b0f47cf51871725d1e71c552237185 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Thu, 25 Jun 2026 23:44:03 +0300 Subject: [PATCH 16/43] fix: objectstore is now a helm hook to ensure it exists before the cluster Signed-off-by: Itay Grudev --- charts/cluster/templates/backup-objectstore.yaml | 1 + charts/cluster/templates/recovery-objectstore.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/charts/cluster/templates/backup-objectstore.yaml b/charts/cluster/templates/backup-objectstore.yaml index 27bf5bf219..5de6cf7bf8 100644 --- a/charts/cluster/templates/backup-objectstore.yaml +++ b/charts/cluster/templates/backup-objectstore.yaml @@ -6,6 +6,7 @@ metadata: namespace: {{ include "cluster.namespace" . }} {{- with .Values.cluster.annotations }} annotations: + "helm.sh/hook": pre-install,pre-upgrade {{- toYaml . | nindent 4 }} {{- end }} labels: diff --git a/charts/cluster/templates/recovery-objectstore.yaml b/charts/cluster/templates/recovery-objectstore.yaml index b56902d99f..9110644e8f 100644 --- a/charts/cluster/templates/recovery-objectstore.yaml +++ b/charts/cluster/templates/recovery-objectstore.yaml @@ -6,6 +6,7 @@ metadata: namespace: {{ include "cluster.namespace" . }} {{- with .Values.cluster.annotations }} annotations: + "helm.sh/hook": pre-install,pre-upgrade {{- toYaml . | nindent 4 }} {{- end }} labels: From dd101f2e978bbbb9dfefd6b6d848092c7db65594 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Thu, 25 Jun 2026 23:44:27 +0300 Subject: [PATCH 17/43] recovery s3 creds not provided on recovery Signed-off-by: Itay Grudev --- charts/cluster/templates/recovery-s3-creds.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/cluster/templates/recovery-s3-creds.yaml b/charts/cluster/templates/recovery-s3-creds.yaml index d70ed2120f..043a2cd749 100644 --- a/charts/cluster/templates/recovery-s3-creds.yaml +++ b/charts/cluster/templates/recovery-s3-creds.yaml @@ -1,4 +1,4 @@ -{{- if and (eq .Values.mode "recovery" ) (eq .Values.recovery.method "object_store") (eq .Values.recovery.provider "s3") (not .Values.recovery.s3.inheritFromIAMRole) .Values.recovery.secret.create }} +{{- if and (eq .Values.mode "recovery" ) (eq .Values.recovery.provider "s3") (not .Values.recovery.s3.inheritFromIAMRole) .Values.recovery.secret.create }} apiVersion: v1 kind: Secret metadata: From e9ad801bf1cd63282889847e6e1e76e1a1b12ec0 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Fri, 26 Jun 2026 00:27:00 +0300 Subject: [PATCH 18/43] fix: backup import and pg_basebackup do not require s3 creds Signed-off-by: Itay Grudev --- charts/cluster/templates/recovery-s3-creds.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/cluster/templates/recovery-s3-creds.yaml b/charts/cluster/templates/recovery-s3-creds.yaml index 043a2cd749..4966ebe600 100644 --- a/charts/cluster/templates/recovery-s3-creds.yaml +++ b/charts/cluster/templates/recovery-s3-creds.yaml @@ -1,4 +1,4 @@ -{{- if and (eq .Values.mode "recovery" ) (eq .Values.recovery.provider "s3") (not .Values.recovery.s3.inheritFromIAMRole) .Values.recovery.secret.create }} +{{- if and (eq .Values.mode "recovery" ) (eq .Values.recovery.provider "s3") (has .Values.recovery.method (list "backup" "import" "pg_basebackup")) (not .Values.recovery.s3.inheritFromIAMRole) .Values.recovery.secret.create }} apiVersion: v1 kind: Secret metadata: From b4a63831e61c51f3f4f9dc2e53a8dd8170eed48b Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Fri, 26 Jun 2026 00:28:20 +0300 Subject: [PATCH 19/43] debug logs on failure for plugin migration Signed-off-by: Itay Grudev --- charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml index 71bfe56249..3c45330f3e 100644 --- a/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml +++ b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml @@ -90,6 +90,9 @@ spec: content: sleep 1 - assert: file: ./04.2-barman-plugin-migration_cluster-assert.yaml + catch: + - podLogs: + selector: cnpg.io/cluster=barman-plugin-migration-cluster - name: Create a buckup with the Barman CNPG-I plugin try: - apply: From ff2ecd34b828982fdcc33ed8dbe00c4f319c1388 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Fri, 26 Jun 2026 00:28:38 +0300 Subject: [PATCH 20/43] deleted backups during cleanup to speed up cleanup Signed-off-by: Itay Grudev --- .../test/barman-plugin-scheduledbackups/chainsaw-test.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/charts/cluster/test/barman-plugin-scheduledbackups/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-scheduledbackups/chainsaw-test.yaml index 7a29e05cc3..e84283ba58 100644 --- a/charts/cluster/test/barman-plugin-scheduledbackups/chainsaw-test.yaml +++ b/charts/cluster/test/barman-plugin-scheduledbackups/chainsaw-test.yaml @@ -28,4 +28,6 @@ spec: try: - script: content: | - helm uninstall --namespace $NAMESPACE scheduledbackups + kubectl --namespace $NAMESPACE delete scheduledbackups.postgresql.cnpg.io --all + kubectl --namespace $NAMESPACE delete backups.postgresql.cnpg.io --all + helm --namespace $NAMESPACE uninstall scheduledbackups From 92748c6b74bb06d31d668eefe8c710e593800e78 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Sun, 28 Jun 2026 01:14:49 +0300 Subject: [PATCH 21/43] fix: incorrect recovery-s3-creds condition Signed-off-by: Itay Grudev --- charts/cluster/templates/recovery-s3-creds.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/cluster/templates/recovery-s3-creds.yaml b/charts/cluster/templates/recovery-s3-creds.yaml index 4966ebe600..cf170a647b 100644 --- a/charts/cluster/templates/recovery-s3-creds.yaml +++ b/charts/cluster/templates/recovery-s3-creds.yaml @@ -1,4 +1,4 @@ -{{- if and (eq .Values.mode "recovery" ) (eq .Values.recovery.provider "s3") (has .Values.recovery.method (list "backup" "import" "pg_basebackup")) (not .Values.recovery.s3.inheritFromIAMRole) .Values.recovery.secret.create }} +{{- if and (eq .Values.mode "recovery" ) (eq .Values.recovery.provider "s3") (not (has .Values.recovery.method (list "backup" "import" "pg_basebackup"))) (not .Values.recovery.s3.inheritFromIAMRole) .Values.recovery.secret.create }} apiVersion: v1 kind: Secret metadata: From af4266ef04404487db64c3c9dd7620932c368fcc Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Sun, 28 Jun 2026 04:19:47 +0300 Subject: [PATCH 22/43] fix: typo in the external clusters section Signed-off-by: Itay Grudev --- charts/cluster/templates/_external_clusters.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/cluster/templates/_external_clusters.tpl b/charts/cluster/templates/_external_clusters.tpl index dc86484716..d94f49ecff 100644 --- a/charts/cluster/templates/_external_clusters.tpl +++ b/charts/cluster/templates/_external_clusters.tpl @@ -26,7 +26,7 @@ externalClusters: {{ with $pluginConfigurationParameters }} {{- toYaml . | nindent 8 -}} {{ end }} - barmanObjectname: {{ include "cluster.fullname" . }}-recovery + barmanObjectName: {{ include "cluster.fullname" . }}-recovery serverName: {{ .Values.recovery.clusterName }} {{- end }} {{- else if eq .Values.mode "replica" }} From 84dce7b76810f7d6228eb45192d857893b9f6aa8 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Sun, 28 Jun 2026 15:35:32 +0300 Subject: [PATCH 23/43] fix: test step order - no base backup Signed-off-by: Itay Grudev --- .../{03-backup.yaml => 02-backup.yaml} | 0 ...t.yaml => 02-backup_completed-assert.yaml} | 0 ...ert.yaml => 02-backup_running-assert.yaml} | 0 ...{03-checkpoint.yaml => 02-checkpoint.yaml} | 0 ...-assert.yaml => 03-data_write-assert.yaml} | 0 ...{02-data_write.yaml => 03-data_write.yaml} | 0 .../chainsaw-test.yaml | 38 ++++++++++--------- 7 files changed, 20 insertions(+), 18 deletions(-) rename charts/cluster/test/barman-plugin-backup-restore/{03-backup.yaml => 02-backup.yaml} (100%) rename charts/cluster/test/barman-plugin-backup-restore/{03-backup_completed-assert.yaml => 02-backup_completed-assert.yaml} (100%) rename charts/cluster/test/barman-plugin-backup-restore/{03-backup_running-assert.yaml => 02-backup_running-assert.yaml} (100%) rename charts/cluster/test/barman-plugin-backup-restore/{03-checkpoint.yaml => 02-checkpoint.yaml} (100%) rename charts/cluster/test/barman-plugin-backup-restore/{02-data_write-assert.yaml => 03-data_write-assert.yaml} (100%) rename charts/cluster/test/barman-plugin-backup-restore/{02-data_write.yaml => 03-data_write.yaml} (100%) diff --git a/charts/cluster/test/barman-plugin-backup-restore/03-backup.yaml b/charts/cluster/test/barman-plugin-backup-restore/02-backup.yaml similarity index 100% rename from charts/cluster/test/barman-plugin-backup-restore/03-backup.yaml rename to charts/cluster/test/barman-plugin-backup-restore/02-backup.yaml diff --git a/charts/cluster/test/barman-plugin-backup-restore/03-backup_completed-assert.yaml b/charts/cluster/test/barman-plugin-backup-restore/02-backup_completed-assert.yaml similarity index 100% rename from charts/cluster/test/barman-plugin-backup-restore/03-backup_completed-assert.yaml rename to charts/cluster/test/barman-plugin-backup-restore/02-backup_completed-assert.yaml diff --git a/charts/cluster/test/barman-plugin-backup-restore/03-backup_running-assert.yaml b/charts/cluster/test/barman-plugin-backup-restore/02-backup_running-assert.yaml similarity index 100% rename from charts/cluster/test/barman-plugin-backup-restore/03-backup_running-assert.yaml rename to charts/cluster/test/barman-plugin-backup-restore/02-backup_running-assert.yaml diff --git a/charts/cluster/test/barman-plugin-backup-restore/03-checkpoint.yaml b/charts/cluster/test/barman-plugin-backup-restore/02-checkpoint.yaml similarity index 100% rename from charts/cluster/test/barman-plugin-backup-restore/03-checkpoint.yaml rename to charts/cluster/test/barman-plugin-backup-restore/02-checkpoint.yaml diff --git a/charts/cluster/test/barman-plugin-backup-restore/02-data_write-assert.yaml b/charts/cluster/test/barman-plugin-backup-restore/03-data_write-assert.yaml similarity index 100% rename from charts/cluster/test/barman-plugin-backup-restore/02-data_write-assert.yaml rename to charts/cluster/test/barman-plugin-backup-restore/03-data_write-assert.yaml diff --git a/charts/cluster/test/barman-plugin-backup-restore/02-data_write.yaml b/charts/cluster/test/barman-plugin-backup-restore/03-data_write.yaml similarity index 100% rename from charts/cluster/test/barman-plugin-backup-restore/02-data_write.yaml rename to charts/cluster/test/barman-plugin-backup-restore/03-data_write.yaml diff --git a/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml index ebd6f539fd..fadc217a37 100644 --- a/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml +++ b/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml @@ -35,29 +35,16 @@ spec: kind: Cluster - podLogs: selector: cnpg.io/cluster=barman-plugin-backup-restore-cluster - - name: Write some data to the cluster - timeouts: - apply: 1s - assert: 30s - try: - - apply: - file: ./02-data_write.yaml - - assert: - file: ./02-data_write-assert.yaml - catch: - - describe: - apiVersion: batch/v1 - kind: Job - - podLogs: - selector: batch.kubernetes.io/job-name=data-test - name: Create a backup try: - apply: - file: ./03-backup.yaml + file: ./02-backup.yaml - apply: - file: ./03-checkpoint.yaml + file: ./02-checkpoint.yaml + - assert: + file: ./02-backup_running-assert.yaml - assert: - file: ./03-backup_completed-assert.yaml + file: ./02-backup_completed-assert.yaml catch: - describe: apiVersion: postgresql.cnpg.io/v1 @@ -67,6 +54,21 @@ spec: kind: Cluster - podLogs: selector: cnpg.io/cluster=barman-plugin-backup-restore-cluster + - name: Write some data to the cluster + timeouts: + apply: 1s + assert: 30s + try: + - apply: + file: ./03-data_write.yaml + - assert: + file: ./03-data_write-assert.yaml + catch: + - describe: + apiVersion: batch/v1 + kind: Job + - podLogs: + selector: batch.kubernetes.io/job-name=data-test - name: Write more data to the database after the backup try: - apply: From 330e6f2c2f690db5f74d1058acedd7c9a88975b6 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Sun, 28 Jun 2026 15:36:05 +0300 Subject: [PATCH 24/43] faster cleanup by removing backups Signed-off-by: Itay Grudev --- .../test/barman-plugin-backup-restore/chainsaw-test.yaml | 2 ++ charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml index fadc217a37..28febc4e25 100644 --- a/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml +++ b/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml @@ -119,4 +119,6 @@ spec: try: - script: content: | + kubectl --namespace $NAMESPACE delete scheduledbackups.postgresql.cnpg.io --all + kubectl --namespace $NAMESPACE delete backups.postgresql.cnpg.io --all helm uninstall --namespace $NAMESPACE barman-plugin-backup-restore diff --git a/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml index 3c45330f3e..1d53e393d3 100644 --- a/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml +++ b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml @@ -173,4 +173,6 @@ spec: try: - script: content: | + kubectl --namespace $NAMESPACE delete scheduledbackups.postgresql.cnpg.io --all + kubectl --namespace $NAMESPACE delete backups.postgresql.cnpg.io --all helm uninstall --namespace $NAMESPACE barman-plugin-migration From 04eeafdcfad19f874a6ab6c43730a87caa483e01 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Sun, 28 Jun 2026 15:36:41 +0300 Subject: [PATCH 25/43] simpler upgrade procedure because the objectstore is a helm hook Signed-off-by: Itay Grudev --- ...rman-plugin-migration_cluster-assert.yaml} | 0 ...> 04-barman-plugin-migration_cluster.yaml} | 0 ...arman-plugin-migration_cluster-assert.yaml | 12 ------- .../04.1-barman-plugin-migration_cluster.yaml | 31 ------------------- .../chainsaw-test.yaml | 15 ++------- 5 files changed, 2 insertions(+), 56 deletions(-) rename charts/cluster/test/barman-plugin-migration/{04.2-barman-plugin-migration_cluster-assert.yaml => 04-barman-plugin-migration_cluster-assert.yaml} (100%) rename charts/cluster/test/barman-plugin-migration/{04.2-barman-plugin-migration_cluster.yaml => 04-barman-plugin-migration_cluster.yaml} (100%) delete mode 100644 charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster-assert.yaml delete mode 100644 charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster.yaml diff --git a/charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster-assert.yaml b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-assert.yaml similarity index 100% rename from charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster-assert.yaml rename to charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-assert.yaml diff --git a/charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster.yaml b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster.yaml similarity index 100% rename from charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster.yaml rename to charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster.yaml diff --git a/charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster-assert.yaml b/charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster-assert.yaml deleted file mode 100644 index 7aed154fc2..0000000000 --- a/charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster-assert.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: postgresql.cnpg.io/v1 -kind: Cluster -metadata: - name: barman-plugin-migration-cluster -status: - readyInstances: 2 - phase: Cluster in healthy state ---- -apiVersion: barmancloud.cnpg.io/v1 -kind: ObjectStore -metadata: - name: barman-plugin-migration-cluster-backups diff --git a/charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster.yaml b/charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster.yaml deleted file mode 100644 index 9abd52993e..0000000000 --- a/charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster.yaml +++ /dev/null @@ -1,31 +0,0 @@ -type: postgresql -mode: standalone -cluster: - instances: 2 - storage: - size: 256Mi - plugins: - - name: barman-cloud.cloudnative-pg.io - enabled: true - isWALArchiver: true - -backups: - enabled: true - method: barmanObjectStore - provider: s3 - endpointURL: "https://minio.minio.svc.cluster.local" - endpointCA: - name: kube-root-ca.crt - key: ca.crt - wal: - encryption: "" - data: - encryption: "" - s3: - bucket: "mybucket" - path: "/barman-plugin-migration/v1" - accessKey: "minio" - secretKey: "minio123" - region: "local" - scheduledBackups: [] - retentionPolicy: "30d" diff --git a/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml index 1d53e393d3..b469420dbf 100644 --- a/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml +++ b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml @@ -74,22 +74,11 @@ spec: kubectl -n $NAMESPACE create secret generic kube-root-ca.crt --from-literal=ca.crt="$(kubectl -n kube-system get configmaps kube-root-ca.crt -o jsonpath='{.data.ca\.crt}')" --dry-run=client -o yaml | kubectl apply -f - helm upgrade \ --namespace $NAMESPACE \ - --values ./04.1-barman-plugin-migration_cluster.yaml \ + --values ./04-barman-plugin-migration_cluster.yaml \ --wait \ barman-plugin-migration ../../ - assert: - file: ./04.1-barman-plugin-migration_cluster-assert.yaml - - script: - content: | - helm upgrade \ - --namespace $NAMESPACE \ - --values ./04.2-barman-plugin-migration_cluster.yaml \ - --wait \ - barman-plugin-migration ../../ - - script: - content: sleep 1 - - assert: - file: ./04.2-barman-plugin-migration_cluster-assert.yaml + file: ./04-barman-plugin-migration_cluster-assert.yaml catch: - podLogs: selector: cnpg.io/cluster=barman-plugin-migration-cluster From 5ffc521676e612830a2cd466db454325a04eeefd Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Sun, 28 Jun 2026 15:52:00 +0300 Subject: [PATCH 26/43] removed backup running assert as it is unreliable. keeping completed only Signed-off-by: Itay Grudev --- .../02-backup_running-assert.yaml | 12 ------------ .../barman-plugin-backup-restore/chainsaw-test.yaml | 2 -- 2 files changed, 14 deletions(-) delete mode 100644 charts/cluster/test/barman-plugin-backup-restore/02-backup_running-assert.yaml diff --git a/charts/cluster/test/barman-plugin-backup-restore/02-backup_running-assert.yaml b/charts/cluster/test/barman-plugin-backup-restore/02-backup_running-assert.yaml deleted file mode 100644 index e708dd4429..0000000000 --- a/charts/cluster/test/barman-plugin-backup-restore/02-backup_running-assert.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: postgresql.cnpg.io/v1 -kind: Backup -metadata: - name: post-init-backup -spec: - cluster: - name: barman-plugin-backup-restore-cluster - method: plugin - pluginConfiguration: - name: barman-cloud.cloudnative-pg.io -status: - phase: running diff --git a/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml index 28febc4e25..61fb0fdba8 100644 --- a/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml +++ b/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml @@ -41,8 +41,6 @@ spec: file: ./02-backup.yaml - apply: file: ./02-checkpoint.yaml - - assert: - file: ./02-backup_running-assert.yaml - assert: file: ./02-backup_completed-assert.yaml catch: From 52a50dbf4b15900ec77a54b7a6be225f210f2d4c Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Sun, 28 Jun 2026 19:33:40 +0300 Subject: [PATCH 27/43] fix: missing minio/mc image tag Signed-off-by: Itay Grudev --- .../test/barman-plugin-backup-restore/00-minio_cleanup.yaml | 2 +- .../cluster/test/barman-plugin-migration/00-minio_cleanup.yaml | 2 +- .../test/barman-plugin-scheduledbackups/00-minio_cleanup.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/cluster/test/barman-plugin-backup-restore/00-minio_cleanup.yaml b/charts/cluster/test/barman-plugin-backup-restore/00-minio_cleanup.yaml index bc381b893f..4d8c6b1d17 100644 --- a/charts/cluster/test/barman-plugin-backup-restore/00-minio_cleanup.yaml +++ b/charts/cluster/test/barman-plugin-backup-restore/00-minio_cleanup.yaml @@ -8,7 +8,7 @@ spec: restartPolicy: OnFailure containers: - name: minio-cleanup - image: minio/mc + image: minio/mc:latest command: ['sh', '-c'] args: - | diff --git a/charts/cluster/test/barman-plugin-migration/00-minio_cleanup.yaml b/charts/cluster/test/barman-plugin-migration/00-minio_cleanup.yaml index 92b77ba8c6..a06dbb2bf8 100644 --- a/charts/cluster/test/barman-plugin-migration/00-minio_cleanup.yaml +++ b/charts/cluster/test/barman-plugin-migration/00-minio_cleanup.yaml @@ -8,7 +8,7 @@ spec: restartPolicy: OnFailure containers: - name: minio-cleanup - image: minio/mc + image: minio/mc:latest command: ['sh', '-c'] args: - | diff --git a/charts/cluster/test/barman-plugin-scheduledbackups/00-minio_cleanup.yaml b/charts/cluster/test/barman-plugin-scheduledbackups/00-minio_cleanup.yaml index 7ee8bc0340..4fef8e057d 100644 --- a/charts/cluster/test/barman-plugin-scheduledbackups/00-minio_cleanup.yaml +++ b/charts/cluster/test/barman-plugin-scheduledbackups/00-minio_cleanup.yaml @@ -8,7 +8,7 @@ spec: restartPolicy: OnFailure containers: - name: minio-cleanup - image: minio/mc + image: minio/mc:latest command: ['sh', '-c'] args: - | From 9eac0045cb4356df262934d96ef86847795b6227 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Sun, 28 Jun 2026 19:38:13 +0300 Subject: [PATCH 28/43] fix: migration test timeout and improved debug logs Signed-off-by: Itay Grudev --- .../test/barman-plugin-migration/chainsaw-test.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml index b469420dbf..756c445f71 100644 --- a/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml +++ b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml @@ -55,7 +55,7 @@ spec: - name: Write some data to the cluster timeouts: apply: 1s - assert: 30s + assert: 1m try: - apply: file: 03-data_write.yaml @@ -68,6 +68,8 @@ spec: - podLogs: selector: batch.kubernetes.io/job-name=data-write - name: Switch the cluster to using Barman CNPG-I for backups + timeouts: + apply: 10s try: - script: content: | @@ -77,9 +79,14 @@ spec: --values ./04-barman-plugin-migration_cluster.yaml \ --wait \ barman-plugin-migration ../../ + - sleep: + duration: 5s - assert: file: ./04-barman-plugin-migration_cluster-assert.yaml catch: + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Cluster - podLogs: selector: cnpg.io/cluster=barman-plugin-migration-cluster - name: Create a buckup with the Barman CNPG-I plugin From 926f107dfc9491dda7b4f723223d64c52df6dffe Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Mon, 29 Jun 2026 04:48:56 +0300 Subject: [PATCH 29/43] fixed hook annotations Signed-off-by: Itay Grudev --- .../cluster/templates/backup-objectstore.yaml | 6 +++--- .../cluster/templates/recovery-objectstore.yaml | 6 +++--- ...-barman-plugin-migration_cluster-assert.yaml | 17 ----------------- 3 files changed, 6 insertions(+), 23 deletions(-) delete mode 100644 charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-assert.yaml diff --git a/charts/cluster/templates/backup-objectstore.yaml b/charts/cluster/templates/backup-objectstore.yaml index 5de6cf7bf8..e1f44e1522 100644 --- a/charts/cluster/templates/backup-objectstore.yaml +++ b/charts/cluster/templates/backup-objectstore.yaml @@ -4,11 +4,11 @@ kind: ObjectStore metadata: name: {{ include "cluster.fullname" . }}-backups namespace: {{ include "cluster.namespace" . }} - {{- with .Values.cluster.annotations }} annotations: "helm.sh/hook": pre-install,pre-upgrade - {{- toYaml . | nindent 4 }} - {{- end }} + {{- with .Values.cluster.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} labels: {{- include "cluster.labels" . | nindent 4 }} {{- with .Values.cluster.additionalLabels }} diff --git a/charts/cluster/templates/recovery-objectstore.yaml b/charts/cluster/templates/recovery-objectstore.yaml index 9110644e8f..ec0bf02454 100644 --- a/charts/cluster/templates/recovery-objectstore.yaml +++ b/charts/cluster/templates/recovery-objectstore.yaml @@ -4,11 +4,11 @@ kind: ObjectStore metadata: name: {{ include "cluster.fullname" . }}-recovery namespace: {{ include "cluster.namespace" . }} - {{- with .Values.cluster.annotations }} annotations: "helm.sh/hook": pre-install,pre-upgrade - {{- toYaml . | nindent 4 }} - {{- end }} + {{- with .Values.cluster.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} labels: {{- include "cluster.labels" . | nindent 4 }} {{- with .Values.cluster.additionalLabels }} diff --git a/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-assert.yaml b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-assert.yaml deleted file mode 100644 index 27991bd3c8..0000000000 --- a/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-assert.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: postgresql.cnpg.io/v1 -kind: Cluster -metadata: - name: barman-plugin-migration-cluster -status: - readyInstances: 2 - phase: Cluster in healthy state -spec: - plugins: - - name: barman-cloud.cloudnative-pg.io - enabled: true - isWALArchiver: true ---- -apiVersion: barmancloud.cnpg.io/v1 -kind: ObjectStore -metadata: - name: barman-plugin-migration-cluster-backups From 3d66b4e7e1105f724b1871bf8c2ed41e975175a2 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Mon, 29 Jun 2026 05:05:13 +0300 Subject: [PATCH 30/43] fix duplicated line Signed-off-by: Itay Grudev --- ...-barman-plugin-migration_cluster-assert.yaml | 17 +++++++++++++++++ .../barman-plugin-migration/chainsaw-test.yaml | 1 - 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-assert.yaml diff --git a/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-assert.yaml b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-assert.yaml new file mode 100644 index 0000000000..27991bd3c8 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-assert.yaml @@ -0,0 +1,17 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: barman-plugin-migration-cluster +status: + readyInstances: 2 + phase: Cluster in healthy state +spec: + plugins: + - name: barman-cloud.cloudnative-pg.io + enabled: true + isWALArchiver: true +--- +apiVersion: barmancloud.cnpg.io/v1 +kind: ObjectStore +metadata: + name: barman-plugin-migration-cluster-backups diff --git a/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml index 756c445f71..9fa26a029c 100644 --- a/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml +++ b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml @@ -73,7 +73,6 @@ spec: try: - script: content: | - kubectl -n $NAMESPACE create secret generic kube-root-ca.crt --from-literal=ca.crt="$(kubectl -n kube-system get configmaps kube-root-ca.crt -o jsonpath='{.data.ca\.crt}')" --dry-run=client -o yaml | kubectl apply -f - helm upgrade \ --namespace $NAMESPACE \ --values ./04-barman-plugin-migration_cluster.yaml \ From 186432d2636a5e75c6a2dd73a9157c5baa1219d2 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Mon, 29 Jun 2026 14:45:41 +0300 Subject: [PATCH 31/43] fix: ability to override the barman plugin configuration Signed-off-by: Itay Grudev --- charts/cluster/templates/_helpers.tpl | 10 ++++++++++ charts/cluster/templates/cluster.yaml | 8 ++++---- .../01-barman-plugin-backup-restore_cluster.yaml | 4 ---- .../05-recovery_backup_pitr_cluster.yaml | 2 +- .../04-barman-plugin-migration_cluster.yaml | 4 ---- .../01-scheduledbackups_cluster.yaml | 4 ---- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/charts/cluster/templates/_helpers.tpl b/charts/cluster/templates/_helpers.tpl index c642655635..6628bac870 100644 --- a/charts/cluster/templates/_helpers.tpl +++ b/charts/cluster/templates/_helpers.tpl @@ -230,3 +230,13 @@ Given a list of objects, returns the first item that matches the key value pairs {{- define "cluster.barmanPluginEnabled" -}} {{- eq (include "helpers.hasKeyValue" (list .Values.cluster.plugins (list (list "name" "barman-cloud.cloudnative-pg.io") (list "isWALArchiver" true)))) "true" -}} {{- end -}} + +{{- define "cluster.barmanPluginRequired" -}} + {{- $required := false -}} + {{- if and .Values.backups.enabled (eq .Values.backups.method "plugin") -}} + {{- if eq .Values.backups.pluginConfiguration.name "barman-cloud.cloudnative-pg.io" -}} + {{- $required = true -}} + {{- end -}} + {{- end -}} + {{- $required -}} +{{- end -}} diff --git a/charts/cluster/templates/cluster.yaml b/charts/cluster/templates/cluster.yaml index dcc164b93b..9ca1bfd9ab 100644 --- a/charts/cluster/templates/cluster.yaml +++ b/charts/cluster/templates/cluster.yaml @@ -159,16 +159,16 @@ spec: {{- range $pluginsWithoutBarman -}} - {{ toYaml . | indent 6 | trim }} {{- end }} - {{- if and (eq (include "cluster.barmanPluginEnabled" .) "true") (and .Values.backups.enabled (eq .Values.backups.method "plugin") (eq .Values.backups.pluginConfiguration.name "barman-cloud.cloudnative-pg.io")) }} + {{- if or (eq (include "cluster.barmanPluginEnabled" .) "true") (eq (include "cluster.barmanPluginRequired" .) "true") }} {{- $barmanPlugin := include "helpers.fetchKeyValue" (list .Values.cluster.plugins (list (list "name" "barman-cloud.cloudnative-pg.io"))) | fromYaml -}} - name: barman-cloud.cloudnative-pg.io - enabled: true - isWALArchiver: true + enabled: {{ or (eq (include "cluster.barmanPluginRequired" .) "true") $barmanPlugin.enabled }} + isWALArchiver: {{ or (eq (include "cluster.barmanPluginRequired" .) "true") $barmanPlugin.isWALArchiver }} parameters: {{- $parameters := (omit (coalesce $barmanPlugin.parameters dict) "barmanObjectName") -}} {{ with $parameters }} {{ toYaml . | indent 8 | trim }} {{- end }} - barmanObjectName: {{ include "cluster.fullname" . }}-backups + barmanObjectName: {{ printf "%s-backups" (include "cluster.fullname" .) | default $barmanPlugin.barmanObjectName }}-backups {{- end }} {{- end }} diff --git a/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster.yaml b/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster.yaml index 13f8220843..141de74506 100644 --- a/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster.yaml +++ b/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster.yaml @@ -4,10 +4,6 @@ cluster: instances: 2 storage: size: 256Mi - plugins: - - name: barman-cloud.cloudnative-pg.io - enabled: true - isWALArchiver: true backups: enabled: true diff --git a/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml b/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml index d32fc02a4d..8b6cb27f59 100644 --- a/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml +++ b/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml @@ -30,7 +30,7 @@ recovery: retentionPolicy: "30d" backups: - enabled: false + enabled: true method: plugin pluginConfiguration: name: barman-cloud.cloudnative-pg.io diff --git a/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster.yaml b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster.yaml index 742ff648ca..430dae6cff 100644 --- a/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster.yaml +++ b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster.yaml @@ -4,10 +4,6 @@ cluster: instances: 2 storage: size: 256Mi - plugins: - - name: barman-cloud.cloudnative-pg.io - enabled: true - isWALArchiver: true backups: enabled: true diff --git a/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml b/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml index f46c3e282f..3962add8c6 100644 --- a/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml +++ b/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml @@ -4,10 +4,6 @@ cluster: instances: 1 storage: size: 256Mi - plugins: - - name: barman-cloud.cloudnative-pg.io - enabled: true - isWALArchiver: true backups: enabled: true From 46087c63840639dbb883d6be4263803c7fd4086d Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Mon, 29 Jun 2026 14:47:31 +0300 Subject: [PATCH 32/43] ability to override enabled and isWALArchiver Signed-off-by: Itay Grudev --- charts/cluster/templates/cluster.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/cluster/templates/cluster.yaml b/charts/cluster/templates/cluster.yaml index 9ca1bfd9ab..b31158ed2f 100644 --- a/charts/cluster/templates/cluster.yaml +++ b/charts/cluster/templates/cluster.yaml @@ -162,8 +162,8 @@ spec: {{- if or (eq (include "cluster.barmanPluginEnabled" .) "true") (eq (include "cluster.barmanPluginRequired" .) "true") }} {{- $barmanPlugin := include "helpers.fetchKeyValue" (list .Values.cluster.plugins (list (list "name" "barman-cloud.cloudnative-pg.io"))) | fromYaml -}} - name: barman-cloud.cloudnative-pg.io - enabled: {{ or (eq (include "cluster.barmanPluginRequired" .) "true") $barmanPlugin.enabled }} - isWALArchiver: {{ or (eq (include "cluster.barmanPluginRequired" .) "true") $barmanPlugin.isWALArchiver }} + enabled: {{ eq (include "cluster.barmanPluginRequired" .) "true" | default $barmanPlugin.enabled }} + isWALArchiver: {{ eq (include "cluster.barmanPluginRequired" .) "true" | default $barmanPlugin.isWALArchiver }} parameters: {{- $parameters := (omit (coalesce $barmanPlugin.parameters dict) "barmanObjectName") -}} {{ with $parameters }} From f9f7d5328087ded8aed831ff2c4b7359bbcbc785 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Mon, 29 Jun 2026 16:40:45 +0300 Subject: [PATCH 33/43] test for plugin configuration passthrough Signed-off-by: Itay Grudev --- ...plugin_explicit_config_cluster-assert.yaml | 14 +++++++ ...barman_plugin_explicit_config_cluster.yaml | 37 +++++++++++++++++ ...plugin_config_override_cluster-assert.yaml | 17 ++++++++ ...barman_plugin_config_override_cluster.yaml | 40 ++++++++++++++++++ .../barman-plugin-explicit/chainsaw-test.yaml | 41 +++++++++++++++++++ 5 files changed, 149 insertions(+) create mode 100644 charts/cluster/test/barman-plugin-explicit/01-barman_plugin_explicit_config_cluster-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-explicit/01-barman_plugin_explicit_config_cluster.yaml create mode 100644 charts/cluster/test/barman-plugin-explicit/02-barman_plugin_config_override_cluster-assert.yaml create mode 100644 charts/cluster/test/barman-plugin-explicit/02-barman_plugin_config_override_cluster.yaml create mode 100644 charts/cluster/test/barman-plugin-explicit/chainsaw-test.yaml diff --git a/charts/cluster/test/barman-plugin-explicit/01-barman_plugin_explicit_config_cluster-assert.yaml b/charts/cluster/test/barman-plugin-explicit/01-barman_plugin_explicit_config_cluster-assert.yaml new file mode 100644 index 0000000000..6d3310f623 --- /dev/null +++ b/charts/cluster/test/barman-plugin-explicit/01-barman_plugin_explicit_config_cluster-assert.yaml @@ -0,0 +1,14 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: barman-plugin-explicit-config-cluster +spec: + plugins: + - name: foo.example.com + enabled: true + isWALArchiver: false + parameters: + foo: bar + - name: barman-cloud.cloudnative-pg.io + enabled: true + isWALArchiver: true diff --git a/charts/cluster/test/barman-plugin-explicit/01-barman_plugin_explicit_config_cluster.yaml b/charts/cluster/test/barman-plugin-explicit/01-barman_plugin_explicit_config_cluster.yaml new file mode 100644 index 0000000000..dce181cf13 --- /dev/null +++ b/charts/cluster/test/barman-plugin-explicit/01-barman_plugin_explicit_config_cluster.yaml @@ -0,0 +1,37 @@ +type: postgresql +mode: standalone +cluster: + instances: 1 + storage: + size: 256Mi + plugins: + - name: foo.example.com + enabled: true + isWALArchiver: false + parameters: + foo: bar + - name: barman-cloud.cloudnative-pg.io + enabled: true + isWALArchiver: true + +backups: + enabled: true + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/barman-plugin-scheduledbackups/v1" + accessKey: "minio" + secretKey: "minio123" + region: "local" + retentionPolicy: "30d" diff --git a/charts/cluster/test/barman-plugin-explicit/02-barman_plugin_config_override_cluster-assert.yaml b/charts/cluster/test/barman-plugin-explicit/02-barman_plugin_config_override_cluster-assert.yaml new file mode 100644 index 0000000000..e595e8bd2f --- /dev/null +++ b/charts/cluster/test/barman-plugin-explicit/02-barman_plugin_config_override_cluster-assert.yaml @@ -0,0 +1,17 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: barman-plugin-config-override-cluster +spec: + plugins: + - name: foo.example.com + enabled: true + isWALArchiver: false + parameters: + foo: bar + - name: barman-cloud.cloudnative-pg.io + enabled: false + isWALArchiver: false + parameters: + foo: bar + barmanObjectName: asd diff --git a/charts/cluster/test/barman-plugin-explicit/02-barman_plugin_config_override_cluster.yaml b/charts/cluster/test/barman-plugin-explicit/02-barman_plugin_config_override_cluster.yaml new file mode 100644 index 0000000000..a06a6eef10 --- /dev/null +++ b/charts/cluster/test/barman-plugin-explicit/02-barman_plugin_config_override_cluster.yaml @@ -0,0 +1,40 @@ +type: postgresql +mode: standalone +cluster: + instances: 1 + storage: + size: 256Mi + plugins: + - name: foo.example.com + enabled: true + isWALArchiver: false + parameters: + foo: bar + - name: barman-cloud.cloudnative-pg.io + enabled: false + isWALArchiver: false + parameters: + foo: bar + barmanObjectName: asd + +backups: + enabled: true + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/barman-plugin-scheduledbackups/v1" + accessKey: "minio" + secretKey: "minio123" + region: "local" + retentionPolicy: "30d" diff --git a/charts/cluster/test/barman-plugin-explicit/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-explicit/chainsaw-test.yaml new file mode 100644 index 0000000000..0fd08835e8 --- /dev/null +++ b/charts/cluster/test/barman-plugin-explicit/chainsaw-test.yaml @@ -0,0 +1,41 @@ +# Tests the Barman Cloud CNPG-I Plugin with explicit plugin configuration +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + name: barman-plugin-explicit +spec: + timeouts: + apply: 1s + assert: 5s + cleanup: 1m + steps: + - name: Install a cluster with a custom plugin section + try: + - script: + content: | + helm upgrade \ + --install \ + --namespace $NAMESPACE \ + --values ./01-barman_plugin_explicit_config_cluster.yaml \ + --wait \ + barman-plugin-explicit-config ../../ + - assert: + file: ./01-barman_plugin_explicit_config_cluster-assert.yaml + - name: Install the cluster with a custom plugin section that overrides the default configuration + try: + - script: + content: | + helm upgrade \ + --install \ + --namespace $NAMESPACE \ + --values ./02-barman_plugin_config_override_cluster.yaml \ + --wait \ + barman-plugin-config-override ../../ + - assert: + file: ./02-barman_plugin_config_override_cluster-assert.yaml + - name: Cleanup + try: + - script: + content: | + helm --namespace $NAMESPACE uninstall barman-plugin-explicit-config + helm --namespace $NAMESPACE uninstall barman-plugin-config-override From fa31befe588cdb2fa9649787df1a7776974e1f20 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Mon, 29 Jun 2026 16:40:55 +0300 Subject: [PATCH 34/43] fix: plugin configuration passthrough Signed-off-by: Itay Grudev --- charts/cluster/templates/cluster.yaml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/charts/cluster/templates/cluster.yaml b/charts/cluster/templates/cluster.yaml index b31158ed2f..623188e6df 100644 --- a/charts/cluster/templates/cluster.yaml +++ b/charts/cluster/templates/cluster.yaml @@ -153,22 +153,23 @@ spec: {{ include "cluster.externalClusters" . | nindent 2 -}} {{ include "cluster.backup" . | nindent 2 -}} - {{- if gt (len .Values.cluster.plugins) 0 }} + {{- if or (gt (len .Values.cluster.plugins) 0) (eq (include "cluster.barmanPluginRequired" .) "true") }} plugins: {{ $pluginsWithoutBarman := include "helpers.omitKeyValue" (list .Values.cluster.plugins (list (list "name" "barman-cloud.cloudnative-pg.io"))) | fromYamlArray }} {{- range $pluginsWithoutBarman -}} - {{ toYaml . | indent 6 | trim }} {{- end }} {{- if or (eq (include "cluster.barmanPluginEnabled" .) "true") (eq (include "cluster.barmanPluginRequired" .) "true") }} - {{- $barmanPlugin := include "helpers.fetchKeyValue" (list .Values.cluster.plugins (list (list "name" "barman-cloud.cloudnative-pg.io"))) | fromYaml -}} + {{- $barmanPlugin := include "helpers.fetchKeyValue" (list .Values.cluster.plugins (list (list "name" "barman-cloud.cloudnative-pg.io"))) | fromYaml }} - name: barman-cloud.cloudnative-pg.io - enabled: {{ eq (include "cluster.barmanPluginRequired" .) "true" | default $barmanPlugin.enabled }} - isWALArchiver: {{ eq (include "cluster.barmanPluginRequired" .) "true" | default $barmanPlugin.isWALArchiver }} + enabled: {{ eq $barmanPlugin.enabled nil | ternary (eq (include "cluster.barmanPluginRequired" .) "true") $barmanPlugin.enabled }} + isWALArchiver: {{ eq $barmanPlugin.isWALArchiver nil | ternary (eq (include "cluster.barmanPluginRequired" .) "true") $barmanPlugin.isWALArchiver }} parameters: - {{- $parameters := (omit (coalesce $barmanPlugin.parameters dict) "barmanObjectName") -}} - {{ with $parameters }} - {{ toYaml . | indent 8 | trim }} + {{- $parameters := (coalesce $barmanPlugin.parameters dict) -}} + {{- $parametersWithoutObjectName := (omit $parameters "barmanObjectName") }} + {{ with $parametersWithoutObjectName }} + {{- toYaml . | indent 8 | trim }} {{- end }} - barmanObjectName: {{ printf "%s-backups" (include "cluster.fullname" .) | default $barmanPlugin.barmanObjectName }}-backups + barmanObjectName: {{ $parameters.barmanObjectName | default (printf "%s-backups" (include "cluster.fullname" .)) }} {{- end }} {{- end }} From 5da6157e05ffbbb6e4aae98e3e947fb13f542d2d Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Tue, 30 Jun 2026 20:12:03 +0300 Subject: [PATCH 35/43] fix: updated objectstore condition based on the new configuration options Signed-off-by: Itay Grudev --- charts/cluster/templates/backup-objectstore.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/cluster/templates/backup-objectstore.yaml b/charts/cluster/templates/backup-objectstore.yaml index e1f44e1522..21e025e16d 100644 --- a/charts/cluster/templates/backup-objectstore.yaml +++ b/charts/cluster/templates/backup-objectstore.yaml @@ -1,4 +1,4 @@ -{{- if and .Values.backups.enabled (eq (include "cluster.barmanPluginEnabled" .) "true") }} +{{- if eq (include "cluster.barmanPluginRequired" .) "true" }} apiVersion: barmancloud.cnpg.io/v1 kind: ObjectStore metadata: From ce2f145519ca7d164a03cef9fbab85262de34e49 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Thu, 2 Jul 2026 11:59:51 +0300 Subject: [PATCH 36/43] added pre-rollback hooks to the objectstores Signed-off-by: Itay Grudev --- charts/cluster/templates/backup-objectstore.yaml | 2 +- charts/cluster/templates/recovery-objectstore.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/cluster/templates/backup-objectstore.yaml b/charts/cluster/templates/backup-objectstore.yaml index 21e025e16d..7bedc6ee58 100644 --- a/charts/cluster/templates/backup-objectstore.yaml +++ b/charts/cluster/templates/backup-objectstore.yaml @@ -5,7 +5,7 @@ metadata: name: {{ include "cluster.fullname" . }}-backups namespace: {{ include "cluster.namespace" . }} annotations: - "helm.sh/hook": pre-install,pre-upgrade + "helm.sh/hook": pre-install,pre-upgrade,pre-rollback {{- with .Values.cluster.annotations }} {{- toYaml . | nindent 4 }} {{- end }} diff --git a/charts/cluster/templates/recovery-objectstore.yaml b/charts/cluster/templates/recovery-objectstore.yaml index ec0bf02454..d1b2f8c4d5 100644 --- a/charts/cluster/templates/recovery-objectstore.yaml +++ b/charts/cluster/templates/recovery-objectstore.yaml @@ -5,7 +5,7 @@ metadata: name: {{ include "cluster.fullname" . }}-recovery namespace: {{ include "cluster.namespace" . }} annotations: - "helm.sh/hook": pre-install,pre-upgrade + "helm.sh/hook": pre-install,pre-upgrade,pre-rollback {{- with .Values.cluster.annotations }} {{- toYaml . | nindent 4 }} {{- end }} From fe51d30581d4a0e32c3ed35af1888be1e7cf6e35 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Thu, 2 Jul 2026 12:00:18 +0300 Subject: [PATCH 37/43] added an additional upgrade assertion Signed-off-by: Itay Grudev --- ...ugin-migration_cluster-healthy-assert.yaml} | 2 ++ ...gin-migration_cluster-upgrading-assert.yaml | 18 ++++++++++++++++++ .../barman-plugin-migration/chainsaw-test.yaml | 4 +++- 3 files changed, 23 insertions(+), 1 deletion(-) rename charts/cluster/test/barman-plugin-migration/{04-barman-plugin-migration_cluster-assert.yaml => 04-barman-plugin-migration_cluster-healthy-assert.yaml} (81%) create mode 100644 charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-upgrading-assert.yaml diff --git a/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-assert.yaml b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-healthy-assert.yaml similarity index 81% rename from charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-assert.yaml rename to charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-healthy-assert.yaml index 27991bd3c8..56204cb54b 100644 --- a/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-assert.yaml +++ b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-healthy-assert.yaml @@ -10,6 +10,8 @@ spec: - name: barman-cloud.cloudnative-pg.io enabled: true isWALArchiver: true + parameters: + barmanObjectName: barman-plugin-migration-cluster-backups --- apiVersion: barmancloud.cnpg.io/v1 kind: ObjectStore diff --git a/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-upgrading-assert.yaml b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-upgrading-assert.yaml new file mode 100644 index 0000000000..61fde5a935 --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-upgrading-assert.yaml @@ -0,0 +1,18 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: barman-plugin-migration-cluster +status: + phase: Upgrading cluster +spec: + plugins: + - name: barman-cloud.cloudnative-pg.io + enabled: true + isWALArchiver: true + parameters: + barmanObjectName: barman-plugin-migration-cluster-backups +--- +apiVersion: barmancloud.cnpg.io/v1 +kind: ObjectStore +metadata: + name: barman-plugin-migration-cluster-backups diff --git a/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml index 9fa26a029c..c90edf325b 100644 --- a/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml +++ b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml @@ -81,7 +81,9 @@ spec: - sleep: duration: 5s - assert: - file: ./04-barman-plugin-migration_cluster-assert.yaml + file: ./04-barman-plugin-migration_cluster-upgrading-assert.yaml + - assert: + file: ./04-barman-plugin-migration_cluster-healthy-assert.yaml catch: - describe: apiVersion: postgresql.cnpg.io/v1 From 0ac2b243c8e6461024030f21d56cdc4b92c2bfc2 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Fri, 3 Jul 2026 10:44:57 +0300 Subject: [PATCH 38/43] fix: typo in test Signed-off-by: Itay Grudev --- charts/cluster/test/barman-plugin-migration/08-data_test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/cluster/test/barman-plugin-migration/08-data_test.yaml b/charts/cluster/test/barman-plugin-migration/08-data_test.yaml index 694a7ba252..5fb4faf395 100644 --- a/charts/cluster/test/barman-plugin-migration/08-data_test.yaml +++ b/charts/cluster/test/barman-plugin-migration/08-data_test.yaml @@ -12,7 +12,7 @@ spec: - name: DB_URI valueFrom: secretKeyRef: - name: recovery-backup-pitr-superuser + name: recovery-backup-pitr-cluster-superuser key: uri image: alpine:3.19 command: ['sh', '-c'] From 14d534056870dc2e53970b3bf524e7c5925419ee Mon Sep 17 00:00:00 2001 From: Abdullah Alaqeel Date: Thu, 2 Jul 2026 17:35:50 +0300 Subject: [PATCH 39/43] test(cluster): fix barman-plugin-migration test assertions The barman-plugin-migration chainsaw test fails consistently in CI. The migration itself works correctly (verified against operator source and the plugin migration docs); the failures are in test assertions of transient states, plus one secret-name typo. - Migration 'Upgrading cluster' phase (step 4): status.phase is set for only a fraction of a second (the operator models rollouts as PhaseUpgrade -> PhaseWaitingForInstancesToBeActive, see tests/e2e/probes_test.go), and helm --wait does not gate CNPG CRDs, so polling always missed it. Replaced with a polling assert on the persistent UpgradingInstance Event. - Backup 'running' phase (step 5): the backup completes in ~10s, faster than polling. Replaced with a polling assert on the persistent backup 'Starting' Event (backup_controller.go:337). - PITR secret name (step 8): referenced recovery-backup-pitr-superuser (release name) instead of recovery-backup-pitr-cluster-superuser (cluster name), causing CreateContainerConfigError. Fixed. Verified end-to-end in isolated fork CI (identical test( cluster ) workflow), including PITR recovery. Signed-off-by: Abdullah Alaqel Signed-off-by: Abdullah Alaqeel --- ...in-migration_cluster-upgrading-assert.yaml | 23 +++++-------------- .../05-backup_running-assert.yaml | 17 +++++--------- .../chainsaw-test.yaml | 4 ---- 3 files changed, 12 insertions(+), 32 deletions(-) diff --git a/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-upgrading-assert.yaml b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-upgrading-assert.yaml index 61fde5a935..6682a100fa 100644 --- a/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-upgrading-assert.yaml +++ b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-upgrading-assert.yaml @@ -1,18 +1,7 @@ -apiVersion: postgresql.cnpg.io/v1 -kind: Cluster -metadata: +apiVersion: v1 +kind: Event +reason: UpgradingInstance +involvedObject: + apiVersion: postgresql.cnpg.io/v1 + kind: Cluster name: barman-plugin-migration-cluster -status: - phase: Upgrading cluster -spec: - plugins: - - name: barman-cloud.cloudnative-pg.io - enabled: true - isWALArchiver: true - parameters: - barmanObjectName: barman-plugin-migration-cluster-backups ---- -apiVersion: barmancloud.cnpg.io/v1 -kind: ObjectStore -metadata: - name: barman-plugin-migration-cluster-backups diff --git a/charts/cluster/test/barman-plugin-migration/05-backup_running-assert.yaml b/charts/cluster/test/barman-plugin-migration/05-backup_running-assert.yaml index c1fa64a4c1..8a0ff0dc64 100644 --- a/charts/cluster/test/barman-plugin-migration/05-backup_running-assert.yaml +++ b/charts/cluster/test/barman-plugin-migration/05-backup_running-assert.yaml @@ -1,12 +1,7 @@ -apiVersion: postgresql.cnpg.io/v1 -kind: Backup -metadata: +apiVersion: v1 +kind: Event +reason: Starting +involvedObject: + apiVersion: postgresql.cnpg.io/v1 + kind: Backup name: post-migrate-backup -spec: - cluster: - name: barman-plugin-migration-cluster - method: plugin - pluginConfiguration: - name: barman-cloud.cloudnative-pg.io -status: - phase: running diff --git a/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml index c90edf325b..9cfea96fb9 100644 --- a/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml +++ b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml @@ -68,8 +68,6 @@ spec: - podLogs: selector: batch.kubernetes.io/job-name=data-write - name: Switch the cluster to using Barman CNPG-I for backups - timeouts: - apply: 10s try: - script: content: | @@ -78,8 +76,6 @@ spec: --values ./04-barman-plugin-migration_cluster.yaml \ --wait \ barman-plugin-migration ../../ - - sleep: - duration: 5s - assert: file: ./04-barman-plugin-migration_cluster-upgrading-assert.yaml - assert: From 2440ed61a38d896685fe509a76e101de5c0f6e50 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Fri, 3 Jul 2026 11:52:40 +0300 Subject: [PATCH 40/43] added migration documentation Signed-off-by: Itay Grudev --- charts/cluster/README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/charts/cluster/README.md b/charts/cluster/README.md index f0374394cc..f69ba1ed69 100644 --- a/charts/cluster/README.md +++ b/charts/cluster/README.md @@ -26,6 +26,42 @@ That being said, we welcome PRs that improve the chart, but please keep in mind single configuration that the operator provides and we may reject PRs that add too much complexity and maintenance difficulty to the chart. +Migrating to the Barman Cloud Plugin +------------------------------------ + +> [!WARNING] +> Starting with version 1.26, native backup and recovery capabilities are +> being **progressively phased out** of the core operator and moved to official +> CNPG-I plugins. This transition aligns with CloudNativePG's shift towards a +> **backup-agnostic architecture**, enabled by its extensible +> interface—**CNPG-I**—which standardizes the management of **WAL archiving**, +> **physical base backups**, and corresponding **recovery processes**. + +Migrating from the Built-in CloudNativePG Backup to the Barman Cloud CNPG-I +plugin is a straightforward, single step process, as the chart creates the +necessary `ObjectStore` resource as a helm hook before the cluster is updated. + +All you have to do is change the backup method from `barmanObjectStore` to +`plugin` and specify the plugin name. The same change should also be applied to +your scheduled backups. + +```diff +backups: + enabled: true +- method: barmanObjectStore ++ method: plugin ++ pluginConfiguration: ++ name: barman-cloud.cloudnative-pg.io + scheduledBackups: + - name: daily-backup + schedule: "0 0 0 * * *" + backupOwnerReference: self +- method: barmanObjectStore ++ method: plugin ++ pluginConfiguration: ++ name: barman-cloud.cloudnative-pg.io +``` + Getting Started --------------- From 2a226bd3c412daa657203fb1946c38c57e80d7fa Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Fri, 3 Jul 2026 12:06:43 +0300 Subject: [PATCH 41/43] improved notes when using a backup plugin Signed-off-by: Itay Grudev --- charts/cluster/templates/NOTES.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/charts/cluster/templates/NOTES.txt b/charts/cluster/templates/NOTES.txt index e9c60d26fa..3092921a33 100644 --- a/charts/cluster/templates/NOTES.txt +++ b/charts/cluster/templates/NOTES.txt @@ -75,6 +75,14 @@ Configuration {{- $image = $image.imageName -}} {{- end }} +{{- $backupPlugin := "" -}} +{{- if eq .Values.backups.method "plugin" -}} + {{- $backupPlugin = (get (include "helpers.fetchKeyValue" (list .Values.cluster.plugins (list (list "isWALArchiver" true))) | fromYaml) "name") -}} + {{- if and (empty $backupPlugin) (eq (include "cluster.barmanPluginRequired" .) "true") -}} + {{- $backupPlugin = "barman-cloud.cloudnative-pg.io" -}} + {{- end -}} +{{- end }} + ╭───────────────────┬──────────────────────────────────────────────────────────╮ │ Configuration │ Value │ ┝━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┥ @@ -87,7 +95,7 @@ Configuration │ Instances │ {{ include (printf "%s%s" "cluster.color-" $redundancyColor) (printf "%-56s" (toString .Values.cluster.instances)) }} │ │ Backups │ {{ include (printf "%s%s" "cluster.color-" (ternary "ok" "error" .Values.backups.enabled)) (printf "%-56s" (ternary "Enabled" "Disabled" .Values.backups.enabled)) }} │ {{- if .Values.backups.enabled }} -│ Backup Provider │ {{ printf "%-56s" (cat (title .Values.backups.method) (eq .Values.backups.method "plugin" | ternary (get (include "helpers.fetchKeyValue" (list .Values.cluster.plugins (list (list "isWALArchiver" true))) | fromYaml) "name") "")) }} │ +│ Backup Provider │ {{ printf "%-56s" (cat (title .Values.backups.method) (empty $backupPlugin | ternary "" (printf "(%s)" $backupPlugin))) }} │ │ Scheduled Backups │ {{ printf "%-56s" $scheduledBackups }} │ {{- end }} │ Storage │ {{ printf "%-56s" .Values.cluster.storage.size }} │ From cc9d4094f34fcddd1463512be2e3874cd3fd6da5 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Fri, 3 Jul 2026 12:12:09 +0300 Subject: [PATCH 42/43] fixed typo in the README Signed-off-by: Itay Grudev --- charts/cluster/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/cluster/README.md b/charts/cluster/README.md index f69ba1ed69..0f398dfd4f 100644 --- a/charts/cluster/README.md +++ b/charts/cluster/README.md @@ -56,7 +56,7 @@ backups: - name: daily-backup schedule: "0 0 0 * * *" backupOwnerReference: self -- method: barmanObjectStore +- method: barmanObjectStore + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io From 11fb4fd7428c642eeaf959fffb130e7ede9b7314 Mon Sep 17 00:00:00 2001 From: Abdullah Alaqeel Date: Mon, 6 Jul 2026 04:12:10 +0300 Subject: [PATCH 43/43] test(cluster): raise scheduledbackups cleanup timeout to 10m The barman-plugin-scheduledbackups test intermittently fails with 'context deadline exceeded' during cleanup. The test logic passes; the failure is the namespace teardown exceeding the 5m cleanup budget. Root cause: the CNPG instance pod has terminationGracePeriodSeconds=1800 and its graceful Postgres shutdown (bounded by smartShutdownTimeout ~180s) takes ~2-3m. On GitHub runners (kind-in-Docker on a constrained VM) that shutdown stretches past 5m under load, so the namespace finalization times out. No finalizer is stuck (Cluster and ObjectStore carry none), and the ObjectStore has no plugin finalizer. Verified by reproducing on an isolated, well-resourced cluster: full cleanup completes in ~3m (pod teardown ~2m + namespace GC ~40s). The 5m budget is simply too tight for the slow-runner case. Raise cleanup to 10m. The shutdown is bounded by smartShutdownTimeout, so this won't grow unbounded; 10m gives safe headroom on GitHub runners. Signed-off-by: Abdullah Alaqeel --- .../test/barman-plugin-scheduledbackups/chainsaw-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/cluster/test/barman-plugin-scheduledbackups/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-scheduledbackups/chainsaw-test.yaml index e84283ba58..97d834a76d 100644 --- a/charts/cluster/test/barman-plugin-scheduledbackups/chainsaw-test.yaml +++ b/charts/cluster/test/barman-plugin-scheduledbackups/chainsaw-test.yaml @@ -7,7 +7,7 @@ spec: timeouts: apply: 1s assert: 2m - cleanup: 5m + cleanup: 10m steps: - name: Install the cluster with ScheduledBackups try: